How would a system tray application be accomplishe

2019-03-11 06:15发布

Windows has the "system tray" that houses the clock and alway-running services like MSN, Steam, etc.

I'd like to develop a wxPython tray application but I'm wondering how well this will port to other platforms. What is the tray equivalent on each platform, and how much manual work would be required to support Windows, OSX and Linux (which shells in particular would be friendliest).

5条回答
Deceive 欺骗
2楼-- · 2019-03-11 06:36

Use Qt: Qt Systray Example

That'll show a systray icon on all platforms that Qt runs on and that support such icons. You'll need to come up with a strategy when systray functionality isn't supported, though.

查看更多
趁早两清
3楼-- · 2019-03-11 06:40

Under OS X you have the Status Menu bar - the right-most items are often status-related things (like battery status, WiFi connections, etc).

Try searching for NSStatusBar and NSMenuExtra. It's almost trivial to turn an application into one that has an NSStatusBar menu and doesn't appear in the Dock. There are tutorials around on how to do it.

查看更多
The star\"
4楼-- · 2019-03-11 06:42

On Linux it really depends - you got diffrent programming environments there, and some window managers don't even have a tray area. Altho, if you use Gtk (and wx is Gtk really), the gtk.StatusIcon is your friend.

Here are some examples of that (haven't checked if they actually work, but should show you the path).

For wx I found some example code here.

查看更多
我命由我不由天
5楼-- · 2019-03-11 06:48

For many Linux desktop systems (Gnome, KDE, etc.) a Freedesktop's SysTray Protocol is implemented. You can try that if any other solution fails.

查看更多
老娘就宠你
6楼-- · 2019-03-11 06:51

wx is a cross-platform GUI and tools library that supports Win32, Mac OS X, GTK+, X11, Motif, WinCE, and more. And if you use it's classes then your application should work on all these platforms. For system tray look at wxTaskBarIcon (http://docs.wxwidgets.org/stable/wx_wxtaskbaricon.html#wxtaskbaricon).

查看更多
登录 后发表回答