PySimpleGUI输出元素换行

问题描述

我正在将PySimpleGUI用作tkinter包装器,它的工作原理很吸引人,但是:

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

当无法显示当前单词时,我可以以某种方式将其更改为换行吗 完全保留剩余的行长?

欢呼

编辑示例图片

Error_Sample

解决方法

Output元素具有属性TKOut,它是TKOutput元素。 output元素的属性TKOutput实际上是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()

输出:

enter image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...