1 回答

TA貢獻1829條經驗 獲得超7個贊
該元素具有元素Output屬性。而 element的屬性實際上是 tkinter對象,您可以使用它來配置包裝模式。TKOutTKOutputoutputTKOutputText
下面是一個簡單的例子:
import PySimpleGUI as sg
layout = [
[sg.Text('GameFinder', font=('Helvetica', 24, 'bold'))],
[sg.In(key='-IN-', size=(40,1)), sg.Button('Search')],
[sg.Output(key='-OUT-', size=(80, 20))],
]
window = sg.Window('Game Finder', layout, element_justification='center').finalize()
window['-OUT-'].TKOut.output.config(wrap='word') # set Output element word wrapping
print('''
i am using PySimpleGUI as a tkinter wrapper and it works like a charm, but:
When i am printing something to the output element it performs a linebreak whenever the given character limit per line is reached.
Can i somehow change it to break line when it can't display the current word fully with the remaining line length?
Cheers
''')
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
window.close()
輸出:
添加回答
舉報