Tkinter and wxPythn are two of the most famous Python GUIs that have been used by the worldwide python developers to create GUIs for their python applications!
This first chapter of the Tkinter and wxPython tutorial will create two simple GUIs for both the Tkinter and wxPython as the starting point for me to write the tutorials about this particular Python GUI topic.
Tkinter is shipped together with Python 3 thus it is included within the Python 3 package but wxPython is a separate third-party python library that you will need to install separately.
You can use the pip command to install wxPython if you are a windows user, as for other OS users such as the Linux and Mac users please search for the online document on how to install the wxPython module on your computer which runs on the Mac and the Linux OS.
Now let me create two simple programs to demonstrate to you the outcome of both GUIs.
Tkinter: Create a simple Hello World GUI
import tkinter as tk win = tk.Tk() win.title("Hello World!") win.mainloop()
As you can see the TK method of the Tkinter class will create the top level window object with “Hello World” as its title and then the program will enter the main loop where it will continue running until the user clicks on the ‘x’ close button on the Tkinter’s window to terminate the Tkinter’s program.
wxPython: Create a simple Hello World GUI
import wx app = wx.App(False) frame = wx.Frame(None, wx.ID_ANY, "Hello World") frame.Show(True) app.MainLoop()
The above wxPython program will create a new wxPython application where the False’s parameter of the wx.App method simply asks the stdout/stderr outcome to not get redirected to the top-level window object. The wx.Frame method will then create the top-level wxPython’s window object! At last that window object will get displayed/started with the Show’s method. The program will enter the main loop and continue running until a user has clicked on the ‘x’ button on the window object to close the program.
Thus which GUI do you prefer? Don’t make the decision yet until you have read the entire Tkinter and wxPython tutorial series in the next few chapters.
If you want to learn more about Python and other programming languages don’t forget to subscribe to this blog so you will get notified whenever the latest article has been published.