Hi all,
I am creating a GUI which first launches a login window.Upon providing correct credentials the complete GUI window should appear.
At the initial launch, along with the login window ,the main GUI window should also appear behind the login window but it should be blank. No controls for the main GUI window should be visible.
After the user types username and password correctly, the main GUI window should display the complete GUI with all the controls.
I am attaching snippet of the code herewith.
In the main function, I am calling the main GUI class ( **MainFrame **) and in the init of the main GUI class I am calling the login window class ( **AP_LoginPanel **) .Inside a function ( OnSubmit ( ) ) in the login window class, I am checking if username and password are correct. If yes, then I need to launch the complete GUI window with all the controls.
Kindly tell me how to do it.
Thanks in advance,
Spondita
class MainFrame(wx.Frame):
def init(self, *args, **kw):
super(MainFrame, self).init(*args, **kw)
AP_LoginPanel()
self.Centre()
self.Show(True)
**def InitUI(self):**
self.panel = wx.Panel(self)
self.st = wx.StaticText(self.panel, label="Welcome")
self.button = wx.Button(self.panel1,label="click")
···
-----
class AP_LoginPanel(wx.Frame):
def init(self):
wx.Frame.init(self,None,style=wx.SYSTEM_MENU | wx.CAPTION |wx.CLOSE_BOX)
self.panel = wx.Panel(self,-1)
self.SetSize((400,250))
self.showLoginBox()
def showLoginBox (self):
infolabel = wx.StaticText(self.panel,label=“Please enter your credentials below to proceed”,pos=(60,40))
self.txt_Username = wx.TextCtrl(self.panel, 1, size=(150, -1))
lbl_Username = wx.StaticText(self.panel, -1, “Username:”)
self.txt_Password = wx.TextCtrl(self.panel, 1, size=(150, -1), style=wx.TE_PASSWORD)
lbl_Password = wx.StaticText(self.panel, -1, “Password:”)
btn_Process = wx.Button(self.panel, -1, “&Login”)
self.panel.Bind(wx.EVT_BUTTON, self.OnSubmit, btn_Process)
sizer.Add(btn_Process,0, wx.LEFT | wx.BOTTOM, 70)
self.panel.SetSizer(sizer)
def OnSubmit(self, event):
UserText = self.txt_Username.GetValue()
PasswordText = self.txt_Password.GetValue()
if UserText == self.username:
if PasswordText == self.password:
self.Destroy()
**## need to call the InitUI() method of the main GUI class MainFrame to display the **
** ## complete UI**
##obj = MainFrame(None)
##obj.InitUI()
def main():
ex =wx.App(0)
mainframe = MainFrame(None)
ex.MainLoop()