【发布时间】:2020-12-03 12:59:08
【问题描述】:
所以我正在尝试启动并运行一个简单的程序来检查 modbus 网络的 GUI。这需要一个巨大的文本字段来显示数据。我正在使用 sg.Text。我遇到的问题是更新时没有附加文本框。我确定我遗漏了一些明显的东西。我需要附加因为程序将如何检查网络然后可能保存整个文本框。我如何使也是可滚动的?我觉得我脑子里放了一个大屁。
import PySimpleGUI as sg
import os.path
# First the window layout in 2 columns
file_list_column = [
[
sg.Text("Search Network?"),
sg.Button('Read Serial'),
sg.Button('Test Modbus'),
],
[
sg.Text("Textbox test.", size=(30, 5), relief=sg.RELIEF_SUNKEN, background_color='white', text_color='black',
enable_events=True, key="-NETWORK LIST-")
],
[
sg.Input(key='-IN-')
],
[
sg.Button('Test'),
sg.Button('Clear'),
sg.Button('Exit')
],
]
# ----- Full layout -----
layout = [
[
sg.Column(file_list_column),
sg.VSeperator(),
]
]
window = sg.Window("Network Troubleshooter", layout)
# Run the Event Loop
while True:
event, values = window.read()
if event == "Exit" or event == sg.WIN_CLOSED:
break
if event == 'Test':
# Update the "output" text element to be the value of "input" element
window['-NETWORK LIST-'].update(values['-IN-'])
if event == 'Clear':
# Update the "output" text element to be the value of "input" element
window['-NETWORK LIST-'].update('')
window.close()
【问题讨论】:
标签: python pysimplegui