python logo

Introduction to GUI

Python hosting: Host, run, and code Python in the cloud!

To create a graphical interface (GUI) in Python you need to make use of a library or module.  There are at least three widely used modules for creating GUIs with Python:

While you can create a graphical user interface (GUI) with any of these modules, they do not have the same features.

Related course:

GUI toolkits


Tk provides basic widgets such as a button, menu, text and label. It is very limited compared to QT4 and WxPython but it is also the oldest module.  It runs on most versions of Mac OS, Linux and Windows.

TkMessage box a messagebox in Tk. GUIs made in Tk do not have a native look.

QT4 and QT5 are developed by the Qt company.  Graphical applications made with QT4 or QT5 run on Windows, Linux/X11 and Mac OS X.  It has tons of widgets including tabs, buttons, item views, table views, progressbars, input fields, calendar views and many more. Compared to Tk it has a lot more widgets available.

Graphical application using PyQt5

WxPython is a module that creates a native GUI look regardless of the operating system used. On Windows it will look as windows application while on Mac OS it will look as a Mac application. This can be a clear advantage compared to QT4 or Tk, depending on your purpose. WxWidgets has many widgets available such as buttons, menu, text but also more advanced widgets as a htmlview or tree control.

wxTabs A window created with wxPython. wxPython has native appearance on all operating systems.

Back





Leave a Reply:




Yusuf Thu, 11 Jun 2015

Am soo much enjoying and learning a lot from this blog. Hopefully in future you want to add these GUI libraries to your list?
1) Kivy
2) PyGTK
3) PyGUI
4) libavg

Thanks for the good blog.

Frank Thu, 11 Jun 2015

Thanks! I'll create tutorials series for other GUI libraries later on.

pyraph Wed, 01 Jun 2016

ive been using cute (the original ide) before start learning python and it was as an alternative to code multiplataform, its far more easy for a freelancer dev to work with it than xamarin
i think its important to state this when talking about cute
it has its own libraries so basically you can reuse almost all the code you write
and its not heavy so even a low-budget pc can manage it without problems

Aliasgar gadli Sun, 28 May 2017

sir, can you explain me more about self keyword in detail... i m still a little bit confused

Frank Mon, 29 May 2017

If you create an object from a class, it's variables need to be set. The self keyword refers to the properties of the class. See also: https://pythonspot.com/en/python-class/