繁体   English   中英

启动 Python 脚本 GUI 最小化/在 Windows 托盘中 | 特金特

[英]Start Python script GUI minimized / in Windows Tray | Tkinter

我已经构建了一个简单的 GUI 应用程序,我正在玩pystray 实际上,我的脚本照常启动,您首先看到的是 GUI。 如果单击退出,GUI 会最小化,并且会生成托盘图标。

现在,我搜索了一种以这种“托盘模式”启动我的脚本的方法,这里有一些信息:

class Hauptfenster:

    # Define a function for quit the window
    def quit_window(icon, item):
        icon.stop()
        fenster.destroy()

    # Define a function to show the window again
    def show_window(icon, item):
        icon.stop()
        fenster.after(0, fenster.deiconify())

    # Hide the window and show on the system taskbar
    @staticmethod
    def hide_window():
        fenster.withdraw()
        image = Image.open(os.path.join(application_path, iconFile))
        menu = (item('Beenden', Frontend.Hauptfenster.quit_window), item('Einstellungen', Frontend.Hauptfenster.show_window))
        icon = pystray.Icon("name", image, "Quicksafe", menu)
        icon.run()

请问我您是否需要更多信息,非常感谢! 此致

背景:我的程序应该在 win10 的自动启动中,但我不想每次重新启动我的电脑时都最小化窗口

我刚刚将我的方法hide_window添加到我的主函数中,当脚本启动时,您会看到一些东西在屏幕上移动了 2 毫秒……但它很快消失了……所以这就是我可以忍受的

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM