Object Manipulation and Frames
Mike Driscoll
kyosohma at gmail.com
Wed Jun 11 10:57:35 EDT 2008
On Jun 11, 9:36 am, uo <yon... at googlemail.com> wrote:
> Hello people,
> I would like to get some advice on the method that i should use to
> develop a cyber billing wxpython app.I had started but i hit a snag
> when i realised i could not launch or fiddle with properties of a
> Frame object within another frame object, what i had intended to do
> was to first launch a login frame where members would login and after
> successful authentication , the frame would be hidden and another
> would be launched for billing...i had a LoginFrame and a BillingFrame
> but after successful auth i found it hard to switch the
> BillingFrame.Show(True), can this be done ...and would making use of
> MDI make it beter? ...and if not could anyone please suggest a
> better/
> workable alternative..Thank you.
I do this sort of thing with a timesheet application I wrote. Here's
what I do:
<code>
class Main(wx.App):
''' Create the main screen. '''
def __init__(self, redirect=False, filename=None):
wx.App.__init__(self, redirect, filename)
self.OnLogin()
def OnLogin(self):
dialog = loginDlg.LoginDlg()
dialog.ShowModal()
self.username = dialog.userTxt.GetValue()
self.password = dialog.passwordTxt.GetValue()
loggedIn = dialog.loggedIn
if loggedIn != True:
sys.exit(0)
dialog.Destroy()
</code>
As you can see, I call a wx.Dialog right after initializing my wx.App.
The dialog is modal, which keeps my wx.App from continuing to load. In
my dialog class, I have some authentication code that loops. The loop
allows the user to retry logging in. If the user hits "Cancel", then I
exit the application using the sys.exit(0) command.
Hopefully this code snippet gives you the general idea. Either way, I
highly recommend subscribing to the wxPython user's group. You'll
learn a lot and there are a lot of helpful (and knowledgeable) people
on there, including a couple of core developers.
You will find the means to join here:
http://wxpython.org/maillist.php
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
More information about the Python-list
mailing list