tags:

views:

303

answers:

5

I haven't gotten far enough into Python to make GUIs yet, so I thought I'd ask here. Can a python app be made with the windows default style GUI, or will it have its own style? The only screenshots I've seen of a python app running with a GUI had this ugly win95 look to it.

+5  A: 

There are Python bindings for every major toolkit: GTK+, Qt, Tk, win32/MFC (not fun to use directly), wx (which in turn uses various other toolkits), Windows.Forms (through IronPython)...so in short, yes, probably.

If you define exactly what "native" should look like on what platform, someone can probably tell you exactly what you want. My favourite GUI toolkit is GTK (using PyGTK) which is native on Gnome and looks pretty good to me on Windows.

Mike Graham
+6  A: 

The "ugly" Windows 95 look is determined by the version of the Common Dialog library.

Supplying a manifest file with the executable (probably your Python implementation) makes Windows use of visual styles, instead of the "ugly" look.

Read more here: http://msdn.microsoft.com/en-us/library/ms997646.aspx

Pindatjuh
+1  A: 

The ugly win95 screenshots are probably a result of TkInter which really is quite ugly, if simple to implement in Python. There are loads of Python GUI libraries, among which, some support Windows. The mentionalbes here are WxPython, which despite their Win95-type screenshots can support native Windows widges. Additionally, as Mike Graham mentioned, there is support for the great GTK+ through PyWin, whose Windows support has really come a long way their Window's screenshots can indicate the extent to which it is well-integrated with the native widget look-and-feel. PyQt uses the QT Toolkit, which also has good windows support, and, of course, there is always the option of using the Win32 wrappers to access the Windows GUI APIs directly (though, the APIs are quite ugly, which is not the wrappers so much as it is the Win32 APIs; this is probably only worth pursuing if you are already familiar with the Windows APIs).

Two more options, somewhat more out of the box, would include leaving CPython behind and leveraging IronPython (which runs on the .NET runtime and hence has access to Windows.Forms, or, to be really obtuse Gtk# via Mono) and Jython (which runs on the JVM and can leverage either the quite messy Swing, which has some native Windows widget support or SWT, which supports native windows widgets).

So, all in all, there are lots of options on Python to leverage the native Windowslibrary.

ig0774
No, it's lack of uxtheme, not presence of TkInter.
Ignacio Vazquez-Abrams
@ignacio-vazquez-abrams I'll accept what you say; I've tended to find that, while TkInter applications use native Windows window controls (the outer part of the frame) the actual widgets (buttons and what not) have been rendered in very ugly block-like shapes more reminiscent of Win95 than XP / Vista / Windows 7. That said, I've mostly used PyGTK when I need GUI elements.
ig0774
+3  A: 

Yes, you can use PyQt, or PySide (another Qt binding), or wxPython. They all support native look & feel.

There's also PyGTK, but gtk apps don't to look so native ..

I personally prefer Qt, so I'd suggest PyQt. If you have issues with the GPL, then you can use PySide (LGPL).

hasen j
the most recent versions of Tkinter also support native widgets (older versions do too, to a lesser extent).
Bryan Oakley
+5  A: 

You (and the rest of the world, really ;)) should take a look at PyGUI, by Greg Ewing. In his own words, it's "a project to develop a cross-platform pythonic GUI API." Not only that, it attempts to generate native-looking GUIs on each of the three major platforms.

When I'd last checked it, more than a year ago, it seemed dead, but now I see there was a new release on February 2010, which is great news.

rbp