【发布时间】:2017-02-01 16:55:23
【问题描述】:
我正在尝试使用 RTL(从右到左)文本方向创建文档
def printExam():
#get the exam questions
rows = db(db.exam_questions.exam == request.vars.exam).select()
# create the documnet
document = Document()
document.add_heading(u"أختبار", 0)
#for row in rows:
row = rows[0]
run = document.add_paragraph().add_run(str(row.question.questionText).decode( "utf-8" ))
font = run.font
font.rtl = True
我遇到了以下异常:
Traceback (most recent call last):
File "C:\Users\web2py-src\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "C:/Users/web2py-src/applications/draft/controllers/question.py", line 96, in <module>
File "C:\Users\web2py-src\gluon\globals.py", line 417, in <lambda>
self._caller = lambda f: f()
File "C:/Users/web2py-src/applications/draft/controllers/question.py", line 68, in printExam
font.rtl = True
AttributeError: 'Font' object attribute 'rtl' is read-only
【问题讨论】:
-
如果您能不厌其烦地正确缩进代码就好了。
-
font.rtl当前设置为什么? -
当我打印它的值时:真
-
如果您不执行
font.rtl = True,您会遇到问题吗? -
如果值已经是
True,则似乎不需要该行。