How to create custom GUI for python program?

I want to create a GUI for a python program with a custom design, I have a layout in Photoshop, and I'm looking for a library that supports a theme or any other library that can do the job.

My GUI contains gradients, borders, border radius, and a custom title bar with custom minimize and close buttons, for example, see the Github client for Windows or any Adobe software installer.

I tried wxPython, I used style=wx.NO_BORDER to remove the title bar and default border added by Windows, but I feel like I am not using the appropriate tool for this job, and I read somewhere that wxPython is mainly intended for look at the native GUI and are not designed for this kind of configuration, so I have to look for something else.

I found the answer here, recommending using PyQT and QML to create high customization in the GUI, but the compiled file is very large.

So what should I use to create a GUI? I also want to compile the program, so I need to do this with a reasonable file size.

+7
python user-interface wxpython pyqt
source share
5 answers

Your initial approach using wxPython is fine, you just need some more style flags for your top wx.Frame :

 wx.NO_BORDER ^ wx.SYSTEM_MENU ^ wx.MINIMIZE_BOX ^ wx.MAXIMIZE_BOX ^ wx.CLOSE_BOX 

This will not only remove the border, but also the system menu, as well as the min / max / close fields.

Then draw your gui background directly on the client area of ​​your top frame. See this tutorial : and note that wx.DeviceContext supports drawing bitmaps and gradient fills.

Now create your custom buttons and place them after the wx.CloseEvent , wx.IconizeEvent and wx.MaximizeEvent events when clicked. Lay them out on your custom frame using either absolute positioning or Sizer . Done.

+4
source share

Graphical user interfaces with wxPython / wxWidgets

You are correct that, in general, wxWidgets aims to provide a natural look and feel, usually using standard controls, but the option does not exist. Install wxPython in the latest version, then install the Docs and Demos package for the same version, and then run the demo and go to the Additional Common Widgets tab, and you will find almost all the features you ask to demonstrate in the AUI demo. It mentions custom closure, minimization, etc., the only thing you're talking about is not that one demo is the gradient buttons. You will also find demonstrations of the gradient and aqua buttons, as well as a zoom bar - a la Mac, but platform independent. Screenshots of the AUI demo and the demo package on the zoom panel:

wxPython AGW AUI Screenshot:

wxPython AGW AUI Screenshot

Demonstration on the enlargement panel:

Zoom bar

Note about file sizes:

I have been using wxPython for several years, and my current main project provides a huge number of functions in 15-20 executable files, but py2exe gives me a set of redistributable files that are less than 35 megabytes in size, including documentation and redistributable libraries - I had one very an experienced person who came up to me and demanded to find out where the rest of my supplied package was hiding — was it online or had I preinstalled it in some other way — he was shocked to find out that he would l all in one zip file.

+2
source share

Qt supports two main ways to customize the look (and feel):

  • Styles For example, Oxygen or native styles such as Windows or Mac. Styles are quite difficult to develop, since they must interact directly with the underlying OS. You probably don't want this. Plus, I don't think styles can be written in Python, but I could be wrong here.

  • Style sheets . These are the usual CSS styles that apply to your GUI. They are very flexible, can be changed at runtime, do not need any other code, can use resources such as images, and can influence or change most of the rendering. This style sheet , for example, just scratches the surface of a possible ...

Note that many users find that user-defined GUI styles are subversive and / or listener, as they usually expect the application to look like a native application, that is, like all other applications. There are good reasons for user graphical interfaces, although, for example, with image processing software, a GUI with less contrast (for example, Adobe, Blender, etc.) is often required, so as not to interfere with the viewed / edited image.

The huge advantage of using widely used tools such as Qt or GTK + and its customization is that usability is generally preferable, while tools designed for games or similar usually show poor usability.

+2
source share

If you want something like a GitHub GUI, try PyGame. The window.NOFRAME property is available to remove a border.

+2
source share

I would recommend pyqt4 or pyside. It has the most reliable gui development for python. It already comes with several styles, such as:

  • for windows
  • WindowsXP
  • WindowsVista li>
  • Motif
  • Cde
  • Plastic
  • Cleanlooks

And you can also create your own styles. This link is a good starting point:

+1
source share

All Articles