我希望有人能帮助我。
基本上,我有一个任意脚本,在这个脚本中,有很多函数,每个函数执行后,也会执行 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.')
这是示例输出
关于python - GUI 屏幕中的 print() 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66381996/