Strange problem!

54 views
Skip to first unread message

Udgam Mehetre

unread,
Oct 2, 2012, 3:47:02 PM10/2/12
to wxpytho...@googlegroups.com
Hello everyone!

The problem I m having, I m not sure if its related to python, wxpython, mysqldb or just me..
Here is what happens:
I open the welcome screen of my project, which opens a login page, which again opens a homepage..

On login page , i have a button event to open the welcome page again..

The respective linking works fine when I start from welcome page..
However, if I start from between, i.e  login page, then my program just refuses to open the welcome page..

The same thing happens for other files as well, i.e the previous programs are not opened if I run a program after it
Note that this before-after sequence is what I have set...

The code I use for opening a new file is:
def GoToLogin(self, event):
       self.Close()
       import login
       login.run()
       event.Skip()

run function in login is as follows:

class login(wx.App):
    def OnInit(self):
        frame = MyLogin(None)
        frame.Show()
        return True
   
# end of class MyLogin



if __name__ == "__main__":
    Login = MyLogin2(0)
    Login.MainLoop()

def run():
    app = login(1)
    app.SetAppName("Login")
    app.MainLoop()
 

Is the problem in programming or in the implementation of such a logic?
Oh, just in case u were wondering, My project uses MySQL to maintain a database..
Plz help!

Thanks,
Udgam

Udgam Mehetre

unread,
Oct 2, 2012, 3:49:57 PM10/2/12
to wxpytho...@googlegroups.com
By the way, each program runs perfectly on its own and also opens the program after it..just that it doesnt open the one before it..

Mike Driscoll

unread,
Oct 2, 2012, 4:11:47 PM10/2/12
to wxpytho...@googlegroups.com
Hi,

What I do when I need to have a login dialog before the main app loads is something like this:

1) In my main frame's init, I load a login dialog and show it modally. This causes any following code to be "paused" so the main app doesn't load unless the user enters the correct credentials.
2) If the right credentials are entered, then you destroy the dialog and the code continues to load the main frame (i.e. welcome page)

I have an example somewhere at home. I should put that on my blog sometime.

- Mike

uvmgr8

unread,
Oct 3, 2012, 9:07:40 AM10/3/12
to wxpytho...@googlegroups.com
I know what u mean...but what i am doing is not just opening login from welcome, but opening welcome after a page which is after login..
In short, after logout, again welcome should open...
And it runs very well if I start from welcome initially...just doesnt work if i start from login..

--
Udgam Mehetre

Cause Laughter Is The Best Medicine :)"

Robin Dunn

unread,
Oct 3, 2012, 7:06:49 PM10/3/12
to wxpytho...@googlegroups.com
On 10/2/12 12:47 PM, Udgam Mehetre wrote:
> Hello everyone!
>
> The problem I m having, I m not sure if its related to python, wxpython,
> mysqldb or just me..
> Here is what happens:
> I open the welcome screen of my project, which opens a login page, which
> again opens a homepage..
>
> On login page , i have a button event to open the welcome page again..
>
> The respective linking works fine when I start from welcome page..
> However, if I start from between, i.e login page, then my program just
> refuses to open the welcome page..
>
> The same thing happens for other files as well, i.e the previous
> programs are not opened if I run a program after it
> Note that this before-after sequence is what I have set...


Rather than making them all be standalone applications, you should
instead have just one wx.App instance for the whole program and simply
create and show the frames or dialogs as appropriate when they are needed.


--
Robin Dunn
Software Craftsman
http://wxPython.org

uvmgr8

unread,
Oct 4, 2012, 8:56:41 AM10/4/12
to wxpytho...@googlegroups.com
 >Rather than making them all be standalone applications, you should instead have just one
 >wx.App instance for the whole program and simply create and show the frames or dialogs as
 >appropriate when they are needed.

Yes,you are right..
By the time I got the problem, I was very much into the hole to combine them all together..
...Maybe I was lazy:p

But anyway, why does it happen? That was my initial question..so that I may understand a bit more of the working of my code...

Mark

unread,
Oct 3, 2012, 11:49:45 AM10/3/12
to wxpytho...@googlegroups.com
You should call MainLoop() once in the whole program. Don't initialize
another wxApp but just directly create one or more new loggin frames
simultaneously. Remeber each frame's handle, and then, you can switch over
them without any trouble.





--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/Strange-problem-tp5714829p5714837.html
Sent from the wxPython-users mailing list archive at Nabble.com.
Reply all
Reply to author
Forward
0 new messages