PyInstaller and wxPython
We'll cover the following...
Now let’s try creating a binary from a simple wxPython script. Here’s the wxPython code that we’ve been using in previous chapters:
Press + to interact
import wxclass DemoPanel(wx.Panel):""""""def __init__(self, parent):"""Constructor"""wx.Panel.__init__(self, parent)labels = ["Name", "Address", "City", "State", "Zip","Phone", "Email", "Notes"]mainSizer = wx.BoxSizer(wx.VERTICAL)lbl = wx.StaticText(self, label="Please enter your information here:")lbl.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD))mainSizer.Add(lbl, 0, wx.ALL, 5)for lbl in labels:sizer = self.buildControls(lbl)mainSizer.Add(sizer, 1, wx.EXPAND)self.SetSizer(mainSizer)mainSizer.Layout()def buildControls(self, label):"""Put the widgets together"""sizer = wx.BoxSizer(wx.HORIZONTAL)size = (80,40)font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)lbl = wx.StaticText(self, label=label, size=size)lbl.SetFont(font)sizer.Add(lbl, 0, wx.ALL|wx.CENTER, 5)if label != "Notes":txt = wx.TextCtrl(self, name=label)else:txt = wx.TextCtrl(self, style=wx.TE_MULTILINE, name=label)sizer.Add(txt, 1, wx.ALL, 5)return sizerclass DemoFrame(wx.Frame):"""Frame that holds all other widgets"""def __init__(self):"""Constructor"""wx.Frame.__init__(self, None, wx.ID_ANY,"Py2Exe Tutorial",size=(600,400))panel = DemoPanel(self)self.Show()if __name__ == "__main__":app = wx.App(False)frame = DemoFrame()app.MainLoop()
If you execute the pyinstaller command against this script, you will see ever more output sent to the screen. It will create 23 files that total 19.4 ...
Access this course and 1400+ top-rated courses and projects.