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).
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).
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.
For many Linux desktop systems (Gnome, KDE, etc.) a Freedesktop's SysTray Protocol is implemented. You can try that if any other solution fails.
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.
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.
Related
I'm trying to find out if I can write python-based windows desktop widgets using python 3.2.2 or higher for windows. The above projects are thoroughly confusing. Do any of them support what I'm looking for? (i.e. can be used with windows and python 3.2.2 and higher?
I did come across this answer (https://askubuntu.com/questions/97023/why-cant-i-import-pygtk-with-python-3-2-from-pydev) but it looks like it only works for non-windows platform.
If non of these above python-projects will work with windows and python 3.2.2, is there an easier way to create rainmeter-like desktop widgets in python 3.2.2 or higher for windows?
To start with the confusion: Gtk is the GIMP toolkit, and all the different things you mention in your question title are related, but not quite the same. PyGTK is the legacy binding between Python and GTK, and PyGObject is the preferred binding if you go down that road.
Here a nice short overview of all the different GUI options for Python development, that should explain those terms briefly so that you have an overview. And as gauden suggested in the comments, wxPython is a very common road for cross-platform applications.
Nowadays you should at least consider Kivy as well, it is fun to program in, and it even gives you options to expand the "cross-platform" bit to mobile devices. It supports transparency (or opacity in Kivy terms)
We are designing open source UI controller application for Plone CMS. The application itself would be just simple start/stop dialog window for Plone daemon process, mainly aimed for Windows users.
However we are hoping to use the same app for OSX and Linux.
We can create the code for Python Qt application, but we feel unsure about the deployment process. In the optimal case we'd hope to create static builds (.exe for Windows, .dmg for OSX) all megabyte so Qt included for our tiny Python script, just to maximize the ease for the end user.
Are there any examples, scripts, etc. to build Qt friendly installers cross-platform? What other best practices we should consider?
PyInstaller is a nice one to create executables and it comes with full PyQt support. It says it can create executables for Windows, OsX and Linux but I've never used it for anything other than Windows. For Windows, it was quite painless and easy.
This doesn't address the packaging/deployment component of your question, but might be a useful side note.... If you haven't already, you may want to consider PySide for your Python bindings, instead of PyQt. The licensing terms are more permissive (LGPL) than PyQt, and may be more appropriate unless you're commercially licensed.
FWIW, I have successfully used py2app with PySide/Qt4 on the Mac, but don't know if it goes cross platform.
There is no tray in Unity under Ubuntu 11.04.
How can I make icon appear somewhere in Unity? wx.TaskBarIcon is not appear anywhere.
Thanks
With Ubuntu Unity desktop environment (i.e. Ubuntu 11.04 or 11.10), you need to "whitelist" your application.
There are different ways to do this using the 'gsettings' application from the command line.
I had to do this to get programs like Skype showing in the system tray again, not just for my own custom apps that use wxPython.
Best answer to give is from the official Documentation:
Under X Window System, the window manager must support either the
System Tray Protocol by freedesktop.org (WMs used by modern desktop
environments such as GNOME >= 2, KDE >= 3 and XFCE >= 4 all do) or the
older methods used in GNOME 1.2 and KDE 1 and 2. If it doesn't, the
icon will appear as a toplevel window on user's desktop.
Because not all window managers have system tray, there's no guarantee
that wxTaskBarIcon will work correctly under X Window System and so
the applications should use it only as an optional component of their
user interface. The user should be required to explicitly enable the
taskbar icon on Unix, it shouldn't be on by default.
http://docs.wxwidgets.org/stable/wx_wxtaskbaricon.html
So this is related to your windowmanager, not programming wxWidgets. wxTaskbarIcon is only reliable under wxMSW, dunno about mac.
Best is to avoid it if you want real XPlatform-Applications.
If you're making a new application, consider using the newer libappindicator library instead – it’s Ubuntu's successor for the systray which should be compatible with GNOME 2.x at least. (I've no idea if either GNOME 3 or KDE support displaying libappindicator notifications anywhere.)
Can you make a universal python application that will run on both OSX and Windows? With the same menu system, etc? Or would you need to make different versions for each OS?
I have built several cross platform applications (Windows / OS X) with wxPython. Practically all of the code translates flawlessly across the two platforms. To put into context, I usually develop the applications on Mac OS side, and if I spend let's say one week hammering out an application, I spend something like a few hours to get it running nicely in Windows.
Usually those hours consist of:
Tweaking minor wxPython visuals (font sizes, colors)
Making nice things like embedded icons
Keyboard shortcuts (CMD vs CTRL)
Main menu
Like you correctly point out, if you want identical main menus you have some work ahead of you on OS X side. I myself have never really bothered, I am fine with having some additional OS X default main menu bits and pieces.
The main menu thing aside though, considering how little tweaking you have to do, I'd say wxPython is the way to go. Together with px2exe on Windows side and py2app on OS X side it packs quite the punch.
Yes. You could build it with Qt for its interface and then you'll have to make judicious use of the os library to make sure that everything plays nicely no matter what operating system it's running on. However when it comes to packaging it for distribution, you'll have to do them separately. For Windows you can use py2exe, which will build a binary package which bundles in the Python runtime and all the libraries you use. I'm not sure how it works in Mac though.
You can try some of cross-platform tools e.g. Appcelerator Titanium Desktop supports python based development.
I'm currently developing an app on my Ubuntu Linux machine. I real life it runs on a windows xp machine with touchpad.
I'm using wxPython as the gui toolkit. In the past I've used .net predominantly but I wanted cross platform.
It really runs without any checks about which os it is running on. (save one check where i read a textfile and i have some trouble with the line endings)
To add on to what has already been given ...
If you rely on any os.system calls, you could also run into places where your code needs to handle the different platforms, well, differently.
As an example, I have an application which has a Help menu option which opens up a pdf file.
My code would be like:
if arch.find("indows"):
os.system("start " + help_filename)
elif arch.find("inux"):
os.system("xdg-open " + help_filename)
else: # really this is the Mac case
os.system("open " + help_filename)
I've been using WxPython and I've tried Tk, but it seems that, while both are good and I'll likely use them for other projects, neither of those appear to be capable of accomplishing the things that I want for my current project (which is fine, they're good at what they do).
Basically what I'm looking for is something that will allow me to make rich graphical GUIs. My specific goal is a window that will draw bitmap buttons, resize the parent window automatically to fit them, and possibly animate the resize with a slide effect and have the buttons fade in. Also being able to have my own window border style instead of the inbuilt one is important to me.
This particular project will be Windows only, so non-portable libraries are fine in this case, though portable ones would be great too.
If I missed how this can be done in either WxPython or Tk, I'm all ears.
PySide: http://www.pyside.org/
The PySide project provides
LGPL-licensed Python bindings for the
Qt cross-platform application and UI
framework. PySide Qt bindings allow
both free open source and proprietary
software development and ultimately
aim to support all of the platforms as
Qt itself.
The Windows version of PySide is quite new and may be considered as a beta version. PySide is API compatible with PyQt.
How about PyQt?
http://www.riverbankcomputing.co.uk/software/pyqt/intro
Just sharing my opinion: Kivy.
Innovative open-source library. Supports both 2.x and 3.x versions of Python.
Kivy - Open source Python library for rapid development of applications
that make use of innovative user interfaces, such as multi-touch apps.
Kivy is based on OpenGL ES 2 and includes native multi-touch for each platform and Android/iOS. It’s an event-driven framework based around a main loop, and is thus also suitable for game development.
Try Pyglet. Its a library for python that makes using OpenGL very easy. You can draw pretty good 2d interfaces using Quads.
I can't tell you what is best because that is subjective but I can give you another option: PyGTK
PyGTK lets you to easily create programs with a graphical user interface using the Python programming language. The underlying GTK+ library provides all kind of visual elements and utilities for it and, if needed, you can develop full featured applications for the GNOME Desktop.
PyGTK applications are truly multiplatform and they're able to run, unmodified, on Linux, Windows, MacOS X and other platforms.