Today I will introduce you to wxPython which is another GUI toolkit besides tkinter which you can use to create GUI for your python application. Phoenix is wxpython for python version 3.x.x which you can download through this link : https://wxpython.org/Phoenix/snapshot-builds/, remember to download the latest version of Phoenix which matches your python version (3.x.x) and your OS. I have Python 3.5.2 installs in my pc that runs on the 64bit windows 10 os so I have downloaded the wxPython_Phoenix-3.0.3.dev2421+1efd6fb-cp35-cp35m-win_amd64.whl file to my pc.
Once you have downloaded the whl file you will need to install it in the python site package folder with this command : pip3 install wxPython_Phoenix-3.0.3.dev2421+1efd6fb-cp35-cp35m-win_amd64.whl.
After you have installed the module, start a new project in NetBeans 8.1 IDE and then create a new python module under the Sources folder just like before. In this new module enter below script.
# Import wxPython module and system module import wx import sys # Subclass wxPython frame class WXFRAME(wx.Frame): def __init__(self, parent, title, size=(200,100)): # Initialize super class wx.Frame.__init__(self, parent, title=title, size=size) # Set frame background color self.SetBackgroundColour('grey') # Create Status Bar self.CreateStatusBar() # Create the Menu menu= wx.Menu() # Add menu items to the menu and bind those items with event listener about = menu.Append(wx.ID_ABOUT, "About", "wxPython Demo") self.Bind(wx.EVT_MENU, self.about_, about) menu.AppendSeparator() exit = menu.Append(wx.ID_EXIT,"Exit"," Exit") self.Bind(wx.EVT_MENU, self.exit_, exit) # Create the menubar menuBar = wx.MenuBar() # Connect menu to menubar and set the MenuBar title menuBar.Append(menu,"File") # Connect the menubar to the frame self.SetMenuBar(menuBar) # Display the frame self.Show() # Exit function to close the program def exit_(self, e): sys.exit(0) # About function to show the about message def about_(self, e): wx.MessageBox("This is a wxPython demo...", "wxPython Demo" ,wx.OK | wx.ICON_INFORMATION) # Create instance of wxPython application app = wx.App() # Ceeate the wx.Frame's instance WXFRAME(None, "wxPython demo", (300,300)) # Run the main GUI event loop app.MainLoop()
Run the module, click on File->About and see the below outcome…
Next click on the Exit item to close the program.
As you can see, wxpython has almost all those features provided by tkinter and many more, you can find out how to use all the Phoenix features through this link : https://wxpython.org/Phoenix/docs/html/classic_vs_phoenix.html