pysimplegui 没有属性 'text'
pysimplegui has no attribute 'text'
一切正常,没有错误然后突然
空闲给出了这个错误:
Traceback (most recent call last):
File "C:\.py", line 28, in <module>
[gui.Button('button3'), gui.text('text')]])
AttributeError: module 'PySimpleGUIWx' has no attribute 'text'
代码:
main_window = gui.Window('window').Layout([[gui.Button('button1'), gui.Button('button2')],
[gui.Button('button3'), gui.text('text')]])
event, values = main_window.read()
while True:
if event == gui.WIN_CLOSED or event == 'button3':
break
有错字-
.Layout([[gui.Button('button1'), gui.Button('button2')],
[gui.Button('button3'), gui.text('text')]])
您忘记了按钮 1
之后的 '
所以python认为文本是属性而不是字符串
编辑 - 如果是在询问时格式打错了,看看这个,这将解决它。
这一行- gui.text('text')
应该是 gui.Text('text')
.text 必须大写 .Text()
AttributeError: module 'PySimpleGUIWx' has no attribute 'text'
应该是错别字,Python区分大小写,所以应该是
gui.Text('text') # Not gui.text('text')
一切正常,没有错误然后突然 空闲给出了这个错误:
Traceback (most recent call last):
File "C:\.py", line 28, in <module>
[gui.Button('button3'), gui.text('text')]])
AttributeError: module 'PySimpleGUIWx' has no attribute 'text'
代码:
main_window = gui.Window('window').Layout([[gui.Button('button1'), gui.Button('button2')],
[gui.Button('button3'), gui.text('text')]])
event, values = main_window.read()
while True:
if event == gui.WIN_CLOSED or event == 'button3':
break
有错字-
.Layout([[gui.Button('button1'), gui.Button('button2')],
[gui.Button('button3'), gui.text('text')]])
您忘记了按钮 1
之后的'
所以python认为文本是属性而不是字符串
编辑 - 如果是在询问时格式打错了,看看这个,这将解决它。
这一行- gui.text('text')
应该是 gui.Text('text')
.text 必须大写 .Text()
AttributeError: module 'PySimpleGUIWx' has no attribute 'text'
应该是错别字,Python区分大小写,所以应该是
gui.Text('text') # Not gui.text('text')