How to do it...

Let's see how to perform this recipe:

  1. First, we create our Python OOP class as we did before when using tkinter, but this time we inherit from and extend the wx.Frame class. We name the class MainFrame.
  2. Create a new Python module and call it GUI_wxPython.py.
  3. Add the following code:
import wx BACKGROUNDCOLOR = (240, 240, 240, 255) class MainFrame(wx.Frame):     def __init__(self, *args, **kwargs):         wx.Frame.__init__(self, *args, **kwargs)         self.createWidgets()         self.Show()     def exitGUI(self, event):       # callback         self.Destroy()     def createWidgets(self):            self.CreateStatusBar()      # wxPython built-in method         self.createMenu()         self.createNotebook() 
  1. Add the following code to create a notebook widget:
 #---------------------------------------------------------- ...

Get Python GUI Programming Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.