PySimpleGUI 输出元素换行符

我正在使用 PySimpleGUI 作为 tkinter 包装器,它就像一个魅力,但是:

当我向输出元素打印某些内容时,只要达到每行给定的字符限制,它就会执行换行符。

当它不能用剩余的行长度完全显示当前单词时,我可以以某种方式将它更改为断行吗?

干杯

编辑样本图像:

http://img4.mukewang.com/646c663e0001b6a306560427.jpg

白猪掌柜的
浏览 141回答 1
1回答

千巷猫影

该元素具有元素Output属性。而 element的属性实际上是 tkinter对象,您可以使用它来配置包装模式。TKOutTKOutputoutputTKOutputText下面是一个简单的例子:import PySimpleGUI as sglayout = [    [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 wrappingprint('''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:        breakwindow.close()输出:
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python