python - GUI 屏幕中的 print() 输出

标签 python pysimplegui

我希望有人能帮助我。

基本上,我有一个任意脚本,在这个脚本中,有很多函数,每个函数执行后,也会执行 print() 来给我更新。我正在使用 Pysimplegui 库进行 GUI,想知道是否有人可以帮助或解释我可以做什么来在 GUI 中显示打印输出

最佳答案

文档中有几种方法可以做到这一点,这里是一种方法。

import PySimpleGUI as sg

# This is the normal print that comes with simple GUI
sg.Print('Re-routing the stdout', do_not_reroute_stdout=False)

# this is clobbering the print command, and replacing it with sg's Print()
print = sg.Print

# this will now output to the sg display.
print('This is a normal print that has been re-routed.')

这是示例输出

enter image description here

关于python - GUI 屏幕中的 print() 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66381996/

相关文章:

python - 是否有 pysimplegui 函数来获取输入光标的位置?

python - 有没有办法在点击它后更新 PySimpleGUI 中的网格

python - 无法使用 mkvirtualenv, "site-packages/_markerlib"权限被拒绝

python - 在Python的For循环中添加SQL查询

python - CP 求解器可以在特定点初始化吗?

python - Flask-script 添加命令和选项

python - Networkx 旅行商问题 (TSP)

python-3.x - 从 API 中提取数据时的等待屏幕

python - 移动 slider 时更改音量

python - 使用 PySimpleGui,如何让按钮起作用?