【问题标题】:PySimpleGui Output Title Bar Name ProblemPySimpleGui 输出标题栏名称问题
【发布时间】:2019-12-05 17:41:30
【问题描述】:

我想使用 pysimplegui 打印类似这样的输出

import PySimpleGUI as sg
print("The age of the universe is", age_of_universe, "Gyr")
print("The age of universe at z = ", z, "is", age_of_universe_at_z,)
print("Lookback time is", lookback_time , "Gyr")
print("Comoving distance to an object at z =", z , "is" , comoving_distance, "Mpc")
print("Luminosity distance to an object at z =", z, "is", luminosity_distance, "Mpc")
print("Angular diameter distance to an object at z =", z, "is", angular_distance, "Mpc")

我尝试使用弹出方法。但是这次弹出窗口中写的东西变成了标题栏的名称

sg.popup('This is the modified LightGreen3 Theme', 'It has black button text')

那么我怎样才能打印这些东西,并可以随意命名标题栏。

谢谢。

注意:我可以接受使用 tkinter 提供的解决方案,但我更喜欢 pysimpleguı

【问题讨论】:

    标签: python user-interface tkinter pysimplegui


    【解决方案1】:

    在 PySimpleGUI 中,当您要设置标题栏文本时要查找的参数是 title。所有弹出窗口都有一个标题参数,就像 Window 对象一样。

    这个弹出窗口有一个标题:

    制作它的代码是:

    sg.popup('This is a popup.....Make sure it is long enough to see title.', title='My own title')
    

    您可以在主文档http://www.PySimpleGUI.org 中找到弹出参数的说明。

    【讨论】:

    • 感谢您的回答。不过我还有一个问题
    • 在我看到的代码中,打印语句中有一些变量,用逗号分隔。所以当把它放在弹出窗口中时。每次它似乎是一个逗号时,它都会开始一个新行。但是我需要在 GUI 上显示这些变量名称,那么我该如何解决这个问题?
    • 一旦超出了弹出功能的能力,您就可以创建自己的窗口,您可以在其中控制包括换行在内的所有内容。 Popup 是一种在高层次上工作的便捷功能。听起来您需要创建一个以您想要的方式工作的自定义窗口。
    • 还有一个打印功能,可以输出到一个滚动的“调试窗口”。这更像是传统的打印功能。它也是一个高级功能,如果它不符合您的要求,用户可以重新创建它。
    • 也许我应该为此提出另一个问题。我不知道如何创建这样的窗口...它写在您共享的文档中吗?
    猜你喜欢
    • 2017-11-23
    • 1970-01-01
    • 1970-01-01
    • 2012-02-17
    • 1970-01-01
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多