It's been quite a few years since I wrote a wxPython application and much
has changed. I'm re-reading wxPIA, on-line docs, and everything else I can
find to get back to speed. Starting this new application I have a main frame
and panel for user login. No errors generated, but the panel does not
display. I'm sure it's a simple change from what worked before (with a frame
and notebook), but I don't see the problem. Please show me what I'm not
seeing.
Code follows (for pw.py):
#!/usr/bin/env python
import wx
class LoginPanel(wx.Panel):
def __init__(self, *args, **kwds):
wx.Panel.__init__(self, *args, **kwds)
# Allow only 3 login attempts before shutting down application
loginCount = 0
self.Panel = wx.Panel(self)
outerBox = wx.BoxSizer(wx.VERTICAL) # main container
unameBox = wx.BoxSizer(wx.HORIZONTAL) # username container
passwdBox = wx.BoxSizer(wx.HORIZONTAL) # password container
buttonBox = wx.BoxSizer(wx.HORIZONTAL) # OK and Cancel buttons
unameLab = wx.StaticText(self.panel, wx.ID_ANY, 'Username: ')
self.uname = wx.TextCtrl(self.panel, wx.ID_ANY, size=wx.Size(200, 25),
style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|
wx.RAISED_BORDER)
passwdLab = wx.StaticText(self.panel, wx.ID_ANY, 'Password: ')
self.passwd = wx.TextCtrl(self.panel, wx.ID_ANY, size=wx.Size(200, 25),
style=wx.TE_PASSWORD|wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|
wx.RAISED_BORDER)
unameBox.Add(unameLab, 0, wx.LEFT|wx.TOP, 5)
unameBox.Add(self.uname, 0, wx.ALL, 5)
passwdBox.Add(passwdLab, 0, wx.LEFT|wx.TOP, 5)
passwdBox.Add(self.passwd, 0, wx.LEFT|wx.TOP, 5)
self.okLogin = wx.Button(self, wx.ID_OK, 'OK')
self.Bind(wx.EVT_BUTTON, self.OnOkLogin, self.okLogin)
self.cancelLogin = wx.Button(self, wx.ID_CANCEL, 'Cancel')
self.Bind(wx.EVT_BUTTON, self.OnCancelLogin, self.cancelLogin)
buttonBox.Add((200, 0), 0)
buttonBox.Add(self.okLogin, 0, wx.ALL, 5)
buttonBox.Add(self.cancelLogin, 0, wx.ALL, 5)
outerBox.Add(unameBox, 0, wx.ALL, 5)
outerBox.Add(passwdBox, 0, wx.ALL, 5)
outerBox.Add(buttonBox, 0, wx.ALL, 5)
panel.SetSizer(outerBox)
panel.Layout()
def OnOkLogin(self, event):
loginCount += 1
if loginCount > 3:
self.Close()
pass
def OnCancelLogin(self, event):
pass
# End of class LoginPanel
class MainFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE|wx.FULL_REPAINT_ON_RESIZE|wx.TAB_TRAVERSAL
wx.Frame.__init__(self, None, wx.ID_ANY, title='PermitWatch', size=(800,600))
def OnFileClose(self, event):
pass
def OnQuit(self, event):
self.Close()
def OnHelpAbout(self, event):
self.helpdlg(event)
# end of class MainFrame
if __name__ == "__main__":
pw = wx.App(0)
frame = MainFrame("PermitWatch")
pw.SetTopWindow(frame)
frame.Show()
pw.MainLoop()
···
----------------------------------------------------------------------------------
Thanks,
Rich