Introduction

There are several platform-independent GUI toolkits for Python: Tkinter, PyQt, wxWidgets, Gtk+, FLTK and PyOpenGL.

Tkinter

Tkinter is the standard GUI package for Python. Tk is a graphical user interface toolkit that takes developing desktop applications to a higher level than conventional approaches. Tk is the standard GUI not only for Tcl, but for many other dynamic languages, and can produce rich, native applications that run unchanged across Windows, Mac OS X, Linux and more.

#!/usr/bin/env python

import Tkinter

master = Tkinter.Tk()
Tkinter.mainloop()

Some widgets of Tkinter: buttons, labels, check buttons, radio buttons, list box, scroll box, progress bar and a few others.

PyQt

PyQt is a set of Python v2 and v3 bindings for Qt application framework. PyQt combines all the advantages of Qt and Python.

PyQt4 and Qt v4 are no longer supported and no new releases will be made. PyQt5 and Qt v5 are strongly recommended for all new development.

#!/usr/bin/env python

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow

app = QApplication(sys.argv)
main = QMainWindow()
main.setWindowTitle("Zhuzhu PyQt5")
main.show()
sys.exit(app.exec_())

Some widgets of PyQt: window, buttons, message boxes, text boxes, menus, tables, tabs, layouts, dialogs, progress bar and a few others.

wxWidgets

wxWidgets is a free, portable GUI class library written in C++ that provides a native look on a number of platforms. Language bindings are available for many languages including Python.

wxPython is the Python binding for wxWidgets. It can be used to create Python GUI. Unlike Qt or Tk which have a custom Qr or Tk look, applications made with wxPython have a native appearance on all platforms.

A simple example:

#!/usr/bin/env python

import wx

app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "Hello World")
frame.Show(True)
app.MainLoop()

Some widgets of wxPython: window, buttons, dialogs, input field, menu and tabs.

References

  1. Python Official Documentation
  2. Python 2.7.16 documentation
  3. Python 3.7.2 documentation
  4. Tkinter
  5. PyQt
  6. wxWidgets
  7. wxPython
  8. Examples in my GitHub


blog comments powered by Disqus

Published

27 January 2019

Tags