wx.TaskBarIcon on Ubuntu 11.04 - python

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

Related

Fonts management on Linux for Python and Tkinter

I have written an application in Python2.7/Tkinter.
I have 2 Linux machines:
1 Xubuntu with python 2.7.4
1 CentOS (5.2) with python 2.7.1 (Unfortunately, and before someone ask, I can't upgrade this machine)
I connect on both machine from my WindowsXP laptop through SSH and I export the display. Xming is installed on the windows machine as X server.
The script is exactly the same on both machine (shared drive mounted on both machine).
In the script I have :
# show which fonts the system know
print tkFont.families()
# configure the default font
default_font = tkFont.nametofont("TkDefaultFont")
default_font.configure(family="Liberation Sans", size="10")
master.option_add("*Font", default_font)
The fonts "Liberation" are installed on both Linux machine and in Xming (and configured).
In the application I used the grid manager, so the font have a big impact on the resulting interface.
When I launch the application from Xubuntu:
Application interface look very nice. tkFont.families show me some
fonts which aren't installed in Xming (but on Xubuntu)
When I launch the application from CentOs:
Application interface is ugly almost unreadable and completely
deformed. tkFont.families display the "liberation" font in the list
ONLY when installed and configured in Xming.
I scratch my head since this morning on this, I even copied the liberation*.ttf files from Xubuntu to all other machines, without success
How can I suppress this difference between the 2 machines, that my interface look the same on both ?
Any help will be greatly appreciated
At a guess, your tk installation server-side relies on the X Core fonts subsystem to render fonts (this is why it shows xming fonts).
This subsystem has been replaced by fontconfig a long time ago (but tk was very late in switching). Centos 5.2 is probably old enough its tk version still relies on the X Core fonts subsystem. However, Fedora and Red Hat stopped exposing system truetype fonts as X Core fonts quite a long time ago (it was breaking legacy applications).
So your solution is :
– either upgrade to a tk that can use fontconfig (or reconfigure it to use fontconfig) : this way it will see the modern fonts installed in Centos, including Liberation
http://wiki.tcl.tk/9015
– or, do all the legacy magic to expose liberation font in xfs (mkfontdir, and friends, as documented in all pre-2000 Linux font howtos). ANd pray that does not break something else, the X core font system is not particularly robust.
https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s1-x-fonts.html
Mid term you'll had to do it the fontconfig way anyway since x core fonts are on the way out (it was already the case when RHEL 5 was released circa 2007).

Deploying Python Qt application cross-platform: Win, OSX, Linux

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.

Python - Best GUI library for the job?

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.

Tkinter removing standard window in Ubuntu

Is there a command similar to "wm_overrideredirect" for Ubuntu? I want My program to be displayed without the standard window.
Ubuntu's desktop manager is Gnome, which should support wm_overrideredirect as well as any other. What's going wrong for you when you try that? Can you show (by editing your Q) some as-tiny-as-possible Python/Tkinter script that does not behave the way you want, and tell us how it does behave and how you'd like to behave?
As noted (obliquely) in the manual:
my_toplevel.master.overrideredirect(True)
I tested this on Ubuntu Lucid, compiz window manager, Python 2.6.5. As the WM protocol is ancient, I don't expect the window manager to be an issue.

How would a system tray application be accomplished on other platforms?

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.

Categories