简体   繁体   中英

Start Python script GUI minimized / in Windows Tray | Tkinter

I´ve built a simple GUI app, and I´m playing with pystray . Actually, my script starts as usual, the first thing you see is the GUI. If you klick on exit, the GUI minimize, and the tray Icon spawns.

For now, i search a way to start my script in this "tray Mode" here are some informations:

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()

Please ask me if you need some more Information and Thanks a lot ! Best regards

Background: My programm should lay in the autostart of win10 , but i dont want to minimize the window each time i restart my pc

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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