Skip to content

Instantly share code, notes, and snippets.

@driscollis
Created November 7, 2014 22:23
Show Gist options
  • Save driscollis/df0d077fd22c79ad7627 to your computer and use it in GitHub Desktop.
Save driscollis/df0d077fd22c79ad7627 to your computer and use it in GitHub Desktop.
wxPython freeze/thaw example
import wx
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial", size=(500,500))
self.btnNum = 1
# Add a panel so it looks the correct on all platforms
self.panel = wx.Panel(self, wx.ID_ANY)
self.panel.Bind(wx.EVT_LEFT_DOWN, self.onClick)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.panel.SetSizer(self.sizer)
def onClick(self, event):
self.Freeze()
btn = wx.Button(self.panel, label="Button #%s" % self.btnNum)
self.sizer.Add(btn, 0, wx.ALL, 5)
self.sizer.Layout()
self.Thaw()
self.btnNum += 1
# Run the program
if __name__ == "__main__":
app = wx.App(False)
frame = MyForm()
frame.Show()
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment