code_junkie

When is “self” required?

Nov 12th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import wx
  2. class TextFrame(wx.Frame):
  3. def __init__(self):
  4. wx.Frame.__init__(self, None, -1, 'Text Entry Example',
  5. size=(300, 100))
  6. panel = wx.Panel(self, -1)
  7. basicLabel = wx.StaticText(panel, -1, "Basic Control:")
  8. basicText = wx.TextCtrl(panel, -1, "I've entered some text!",
  9. size=(175, -1))
  10. basicText.SetInsertionPoint(0)
  11. pwdLabel = wx.StaticText(panel, -1, "Password:")
  12. pwdText = wx.TextCtrl(panel, -1, "password", size=(175, -1),
  13. style=wx.TE_PASSWORD)
  14. sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6)
  15. sizer.AddMany([basicLabel, basicText, pwdLabel, pwdText])
  16. panel.SetSizer(sizer)
  17.  
  18. import wx
  19. class ButtonFrame(wx.Frame):
  20. def __init__(self):
  21. wx.Frame.__init__(self, None, -1, 'Button Example',
  22. size=(300, 100))
  23. panel = wx.Panel(self, -1)
  24. self.button = wx.Button(panel, -1, "Hello", pos=(50, 20))
  25. self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
  26. self.button.SetDefault()
  27. def OnClick(self, event):
  28. self.button.SetLabel("Clicked")
Add Comment
Please, Sign In to add comment