By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,534 Members | 1,299 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,534 IT Pros & Developers. It's quick & easy.

Object Manipulation and Frames

P: n/a
uo
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.
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Jun 11, 9:36*am, uo <yon...@googlemail.comwrote:
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
Jun 27 '08 #2

P: n/a
<snip>
Thanks alot Mr.Driscoll, that snippet of code helped me alot..but i
was of the idea that the application should be cyclic in nature, that
it hould not exit even on failure to authenticate the user.My idea is
that once logged in i should be able to bring back the ligin screen on
full screen without the Title bar once the user's session is through,
could you/anyone please guide me on how i can acheive this.Thanks alot.

The application is "cyclic" in that it basically runs in an infinite
loop until you exit the application. The login screen part of it can
be cyclic too. Basically what you want will be in your
"loginDlg.LoginDlg()" code, which is the dialog that you show to the
user to login with. In there you can have. In my original application,
I have a function that does the authentication for me and returns
either True or False. If False (i.e. bad credentials), then I display
a modal dialog telling the user to try again.

Since all of my login dialog code is in a separate module, I can reuse
it at any time. So if I need to display it again, I just create a new
instance and the user can login again or some other user can login. In
your case, I would add some code to check if the main frame of your
application was visible or enabled or something and hide or disable it
when I re-display the login dialog.

Hopefully that all makes sense. If not, let me know.

Mike
Aug 4 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.