Frank Millman wrote:
Now I want to set up a login procedure before the user gets to the menu.
The
complete sequence must be like this -
user is prompted for userid and password
if ok, a list of valid companies is presented for selection
if ok, a list of valid modules is presented for selection
if ok, the menu for that module is displayed - this is the menu
described
above
on exit from the menu, the list of modules must be redisplayed
on exit from the list of modules, the list of companies must be
redisplayed
on exit from the list of companies, the user will be logged off
The problem is that this requires a "main loop" of some sort, which runs
independently from wxPython's app.MainLoop(). I cannot figure out where to
run my loop from.
Thanks very much to Jeff and Robin for your replies. You have helped to
shift my thinking forwards a bit, but my mind is still stuck.
Jeff, I understood your suggestion about hiding the frame, calling the login
dialog, and then either showing the frame if ok, or closing it if not ok.
All this must happen inside wxApp(), before wxMainLoop() has started. I did
not realise that you could call a dialog before starting the main loop, but
it works, and is good to know. I did have one problem - under GTK, if you
call the dialog before showing the frame you get some error messages such as
the following -
Gdk-CRITICAL **: file gdkgc.c: line 689 (gdk-gc-set-clip-rectangle):
assertion 'gc != NULL' failed.
However, the program continues ok. I found a workaround by showing the frame
and then immediately hiding it. That made the error messages go away, but
under MSW, you see a flash as the frame is shown and then hidden. I got
around that (sort of) by creating the frame with an initial size of (1,1) -
that way you do not notice the flash.
However, I am still stuck with the rest of my problem of creating a
navigation path of company, then module, then menu, and then allowing
backtracking up the path and back down another leg. I understand Robin's
comment about thinking about it as various events, but I am battling to
identify the events. I am also battling to decide whether to call each
window as a frame or as a dialog - both can work, but the interaction is
very different.
If I use frames, and each node of the path calls another frame, all frames
will be active concurrently, and the user can switch between them. This will
be confusing.
If I use dialogs, I have two problems. Firsly, what event should trigger the
first dialog. Secondly, once the user has launched a program from the menu,
if the dialog is still active it will not allow access to the program frame.
If I close the dialog, how will I get back to where I was when the program
is closed.
I am thinking out loud now, but it is worth trying to follow through my
thoughts to see if this makes sense. What if I have a number of classes,
each with its own panel, to handle each of the nodes. The frame's __init__
routine will invoke the first class. When the user has made a selection, the
panel invokes a method in the *frame* class, which then invokes the class
that contains the next panel. That way the first panel will die a natural
death (or must I destroy it?), and the second panel becomes active. That way
there is only one frame active all the time, and no dialogs. When a program
is launched, a second frame will be created, but now it is ok for them both
to be active - that is what I want.
I will try this scheme tomorrow - it is getting late now - but I will post
this as well to see what comments I get. I still feel I may be missing a
simpler way to achieve this.
Thanks for any feedback.
Frank Millman