簡體   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