简体   繁体   中英

Can a native-looking GUI be made with Python

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.

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

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.

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.

There are loads of Python GUI libraries , among which, some support Windows. The mentionables 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM