python - GUI 屏幕中的 print() 输出
问题描述
我希望有人能帮助我。
基本上,我有一个任意脚本,在这个脚本中,有很多函数,在每个函数执行后,print() 也会执行给我一个更新。我正在使用用于 GUI 的 Pysimplegui 库,并且想知道是否有人可以帮助或解释我可以做些什么来在 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.')
这是示例输出
推荐阅读
- javascript - 使用 Puppeteer 从 Antd Datepicker 中选择日期
- excel - VBA xlUp 未正确选择范围
- c# - 如果两者都在等待用户响应,则 await Console.In.ReadLineAsync() 和 Console.In.ReadLine() 之间是否有区别?
- node.js - 面临错误:创建存储库后在 GitHub 上托管网站时
- javascript - 当它的值为真时,我需要设置复选框
- android - 无法删除 Dart not a valid package name 错误
- java - android中Retrofit的POST方法的分页库
- python - 将 chia 图检查的输出从控制台保存到文件
- c++ - c mysql_real_connect connect wrong host
- c# - how to read template excel file and save as different file using Openxml without modifying the old file?