PySimpleGUI 输出元素换行符
PySimpleGUI Output element linebreak
我正在使用 PySimpleGUI 作为 tkinter 包装器,它的工作原理非常棒,但是:
当我向输出元素打印内容时,它会执行换行
每当达到每行给定的字符数限制时。
当它无法显示当前单词时,我能以某种方式将其更改为换行吗
完全使用剩余的行长度?
干杯
编辑示例图片:
Output
元素有一个 属性 TKOut
即 TKOutput
元素。而 TKOutput
元素的属性 output
实际上是 tkinter Text
对象,您可以使用它来配置包装模式。
下面是一个简单的例子:
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()
并且输出:
我正在使用 PySimpleGUI 作为 tkinter 包装器,它的工作原理非常棒,但是:
当我向输出元素打印内容时,它会执行换行 每当达到每行给定的字符数限制时。
当它无法显示当前单词时,我能以某种方式将其更改为换行吗 完全使用剩余的行长度?
干杯
编辑示例图片:
Output
元素有一个 属性 TKOut
即 TKOutput
元素。而 TKOutput
元素的属性 output
实际上是 tkinter Text
对象,您可以使用它来配置包装模式。
下面是一个简单的例子:
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()
并且输出: