I usually work on a Linux system, but I have a situation where I need to write a client app that would run on windows as a service. Can someone help me or direct, on how to build a system tray app (for example like dropbox) for the windows environment, which gets started on OS startup and the icon sits in the TaskBar and on clicking the app icon presents a menu.
My scripting language is python. Thanks.
Step 1 − Go to the SETTINGS window and choose System. Step 2 − In the SYSTEM window, select Notifications & actions. Here you can select the option that reads “Select which icons appear on the taskbar”.
Select Start , select the arrow next to All apps, right-click the app, then select More > Pin to taskbar. If the app is already open on the desktop, press and hold (or right click) the app's taskbar icon, and then select Pin to taskbar.
To create a System Tray icon of a tkinter application, we can use pystray module in Python. It has many inbuilt functions and methods that can be used to configure the system tray icon of the application. To install pystray in your machine, you can type "pip install pystray" command in your shell or command prompt.
You do this using the pywin32 (Python for Windows Extensions) module.
Example Code for Python 2
Similar Question
To make it run at startup you could mess around with services but it's actually much easier to install a link to the exe in the users "Startup Folder".
Windows 7 and Vista
c:\Users\[username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Windows XP
c:\Documents and Settings\[username]\Start Menu\Programs\Startup
There are (at least) a couple of libraries openly available for this now:
I just started using infi.systray
in a project, and it's worked well for me. Here's how little code you need to do something very basic (taken from their docs):
from infi.systray import SysTrayIcon def say_hello(systray): print("Hello, World!") menu_options = (("Say Hello", None, say_hello),) systray = SysTrayIcon("icon.ico", "Example tray icon", menu_options) systray.start()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With