Bug? wxStaticBoxSizer on winXP

After upgrading to 2.4.0.7 the frame around wxStaticBoxSizer has
disappeared.
Is this a bug or feature? Is it possible to "switch on" the frame?

I'm using (winXP/python2.2.2)

Jens

···

**********************************************************************
Neither the confidentiality nor the integrity of this message
can be guaranteed following transmission on the Internet.
This message has been swept by MAILsweeper at DNV for
the presence of computer viruses.
**********************************************************************

Hi all,

I think this is a really dumb question, but I just cannot figure it out.

I posted a question recently about launching a program from a menu. Robin
gave me the principle, and I got it working nicely. Briefly it works like
this.

The program to be launched has a frame, which has a panel, which has all the
necessary controls on it. The menu program, which actually runs
app.MainLoop(), also has a frame, which presents a menu in the form of a
listview, which allows the user to make a selection. A routine driven from
EVT_LIST_ITEM_ACTIVATED launches the selected program by importing it,
creating an instance of its frame object, with itself as the parent, and
calling frame.Show(True). The result is that both frames are active, and the
user can switch between them, launching another program if required.

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.

My first attempt (and so far still my best one) works like this. Starting
the application runs a frame with a panel that has text controls for the
userid and password, and buttons for ok and cancel. I have an EVT_BUTTON
routine which runs from the ok button. Having checked that the password is
valid, it displays a dialog for selection of company, then a dialog for
selection of module, then a dialog for the module's main menu. The menu
launches the selected program as before. The problem is that all this is
running off the EVT_BUTTON routine, so control immediately reverts back to
the first frame, which is still running a modal dialog, so you cannot do any
work in the second frame.

The difference between the two methods is that in my original method, the
first frame is "paused" waiting for a listview selection while the second
frame is active, but now I have no obvious place to "pause" the first frame
while the second frame is active.

I am sure that my approach is wrong and there is a simple way to do what I
want, but I have messed around for hours without success. Please can someone
tell me what I am missing.

Frank Millman

Have you looked at wxWizard?
I haven't used it (yet), but it sounds like what you need.

- Sam

···

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

Hi Frank,
for my final thesis at the university i also want to make a panel with a
login user id check and passwd check.
can i get a copy of the program or otherwise some hints how to approach
this..
i am a super computer hero, so everything is bugging and debugging here for
me...
it would help me a lot.

regards,

Stephan

···

-----Original Message-----
From: Frank Millman [mailto:frank@chagford.com]
Sent: Thursday, June 05, 2003 4:07 PM
To: wxPython-users@lists.wxwindows.org
Subject: [wxPython-users] Dumb question

Hi all,

I think this is a really dumb question, but I just cannot figure it out.

I posted a question recently about launching a program from a menu. Robin
gave me the principle, and I got it working nicely. Briefly it works like
this.

The program to be launched has a frame, which has a panel, which has all the
necessary controls on it. The menu program, which actually runs
app.MainLoop(), also has a frame, which presents a menu in the form of a
listview, which allows the user to make a selection. A routine driven from
EVT_LIST_ITEM_ACTIVATED launches the selected program by importing it,
creating an instance of its frame object, with itself as the parent, and
calling frame.Show(True). The result is that both frames are active, and the
user can switch between them, launching another program if required.

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.

My first attempt (and so far still my best one) works like this. Starting
the application runs a frame with a panel that has text controls for the
userid and password, and buttons for ok and cancel. I have an EVT_BUTTON
routine which runs from the ok button. Having checked that the password is
valid, it displays a dialog for selection of company, then a dialog for
selection of module, then a dialog for the module's main menu. The menu
launches the selected program as before. The problem is that all this is
running off the EVT_BUTTON routine, so control immediately reverts back to
the first frame, which is still running a modal dialog, so you cannot do any
work in the second frame.

The difference between the two methods is that in my original method, the
first frame is "paused" waiting for a listview selection while the second
frame is active, but now I have no obvious place to "pause" the first frame
while the second frame is active.

I am sure that my approach is wrong and there is a simple way to do what I
want, but I have messed around for hours without success. Please can someone
tell me what I am missing.

Frank Millman

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

This doesn't seem like such a dumb question to me. Handling authentication properly is almost always tricky.

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 basic outline I'd use is closer to your first (passwordless) program than your current attempt. Your wxApp should create the selection frame as it currently does, except that you *don't* want to Show() it yet. In fact, you should call frame.Show(False). Then you should call your modal dialog (or wxWizard) to check password, etc. If the password is incorrectly specified, you can exit the dialog and abort the program (immediately call frame.Close(), or equivalent). If the password *is* correct, then you can Show(True) your frame, possibly after populating the list based off of selections in the dialog/wxWizard.

In short, you're not getting the password before you *create* your first frame. Instead, you're getting it before you *show* the frame, but the frame already exists, so you have something to go back to when you're done with the modal dialog(s).

Jeff Shannon
Technician/Programmer
Credit International

Please send a sample that shows this problem.

···

Jens.Bloch.Helmers@dnv.com wrote:

After upgrading to 2.4.0.7 the frame around wxStaticBoxSizer has
disappeared.
Is this a bug or feature? Is it possible to "switch on" the frame?

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

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.

Don't think about it as a loop but rather various events (transitioning from one window to another) that need to handled like any other event. You just need to identify the points where a transition should take place (a new window needs created, or an existing one is being closed) and then show/hide as appropriate.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Jens,

I am on XP Prof, rest is the same as you and wxStaticBoxSizer has a frame, if I use Win XP Theme (in display properties and have the wxPython manifest file) then it shows a light grey line.

Here is relevant code I use:

        vintageSB = wxStaticBox(self, -1, "Vintage and Maturity:")
        sbVintageSizer = wxStaticBoxSizer(vintageSB, wxVERTICAL)
         .... add some stuff to sbVintageSizer
        rcSizer.Add(sbVintageSizer, row=1, col=0, flag=wxTOP|wxBOTTOM, border=5)

rcSizer is a RowColumnSizer and I use the Top and Bottom flag with border=5 to have a nice distance between the border lines and the stuff contained in sbVintageSizer.

See you
Werner

···

Jens.Bloch.Helmers@dnv.com wrote:

After upgrading to 2.4.0.7 the frame around wxStaticBoxSizer has
disappeared.
Is this a bug or feature? Is it possible to "switch on" the frame?

I'm using (winXP/python2.2.2)

Jens

**********************************************************************
Neither the confidentiality nor the integrity of this message can be guaranteed following transmission on the Internet. This message has been swept by MAILsweeper at DNV for the presence of computer viruses.
**********************************************************************

How do i set the python path correctly for the pymat? i pointed it already
to my pymat.pyd and the right dll files in the matlab dir. but still got the
error:

Traceback (most recent call last):
  File "<pyshell#7>", line 1, in ?
    import pymat
ImportError: DLL load failed: The specified procedure could not be found.

anyone?
Stephan

Hi Frank,
for my final thesis at the university i also want to make a panel with a
login user id check and passwd check.
can i get a copy of the program or otherwise some hints how to approach
this..
i am a super computer hero, so everything is bugging and debugging here

for

me...
it would help me a lot.

regards,

Stephan

With pleasure, Stephan.

In fact I will go one better, and attach the original program that was
kindly posted by someone a couple of months ago showing how to do this - I
can't remember your name, sorry, but thanks very much, it saved me quite a
bit of work.

I just store the name and password (encrypted, obviously) in a database, and
compare them at login. I suppose you could encrypt the password again and
decrypt it at login time if you were really paranoid, but I have not
bothered with this.

Hope it helps.

Frank Millman

login.py (1.83 KB)

···

----- Original Message -----
From: "stephan huijgen" <s.huijgen@student.tudelft.nl>
To: <wxPython-users@lists.wxwindows.org>
Sent: Thursday, June 05, 2003 4:44 PM
Subject: RE: [wxPython-users] Dumb question

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

Frank Millman wrote:

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.

That sounds like a good plan. If you expect to be using each panel multiple times, you might be able to just hide each one, so that only one is visible at a time, but it's probably easier to just Destroy() each panel when you're done with it and put a new panel in the frame.

I'm not completely certain, but I think that this is essentially the approach used by wxWizard. You really should look into that and see if it will suit your needs. If so, that'll be simpler than rolling your own.

Jeff Shannon
Technician/Programmer
Credit International

This problem sounds a bit like one we had recently: how to shutdown a
complex piece of electronics with various stages of shutdown (with user
interaction and decisions at each stage).

We created a custom event which kept track of the current
"shutdown-level" of the system. The eventhandler for this event calls
different subroutines depending on the "shutdown-level" of the event.
I.e. after completion of the "Shut-down Level 1" subroutine, another
event is posted to the main windows by the subroutine, a "Shutdown Level
2" event. Comlpetion of Shutdown level 3 leads to Level 4 etc. If at any
stage in the process the user wants to abort the shutdown, he can simple
reset the Shutdown level to something else and so interupt the chain.

By breaking the process into small stages everything can be directed
from the wxPython Mainloop, using events.

In your case, each stage in the chain would manage the creation and
destruction of and GUI frames for user interaction, ensuring that you
don't have too many windows in existence at one time. Extra data could
be associated with the event is required.

Bryan

···

On Fri, 2003-06-06 at 14:39, Frank Millman wrote:

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

--
Bryan Cole
Teraview Ltd., 302-304 Cambridge Science Park, Milton Road, Cambridge CB4 0WG, United Kingdom.
tel: +44 (1223) 435380 / 435386 (direct-dial) fax: +44 (1223) 435382

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.

Phew, I seem to have got it working at last. Thanks again to Robin, Jeff,
and also Bryan for their valuable input.

There was a key to the whole thing, which was actually fairly obvious but
caused me much confusion until the penny dropped. Typically a window
responds to user events, and handles the events itself using its own
methods. I wanted a chain of windows, but I could not figure out how to pass
control from one window to the other and back again. The simple answer was
to have a top-level frame which is never shown, but acts as the traffic cop
for a series of child frames. It creates each one when necessary, and it is
up to each child frame to notify the parent frame when it is being closed.
The parent extracts any information it needs from the child, destroys it,
and then creates the next one.

My first attempt used panels instead of child frames, but this did not work.
I don't know whether there is an inherent problem with this approach, or
whether I just got something wrong, but I did not waste any time with this
and tried another approach.

My second attempt was to create all the child frames up front, and then use
the traffic cop to show them or hide them as necessary. This approach looked
as if it was working, until I hit a strange bug that took me ages to track
down. Most of my child frames allow a selection from various options that
are stored in a database. I have a standard routine to handle this, which
uses a grid, that is linked to a grid table, that is linked to a database
cursor. It is not strictly necessary in this case as the number of options
is quite small, but my standard routine handles anything from one to a
million rows, so I use it throughout my system. The bug was that it worked
the first time a frame was shown, but for every subsequent call it used a
reference to the first grid table instead of the new one. I remember reading
that you cannot change the grid table once it is established, but as I was
creating the grid from scratch each time I thought it would work. It seems
that the reference to the grid table is linked to the window the grid is in,
rather than the grid itself.

So my third and successful attempt was to create classes for all my child
frames up front, but not instantiate them. The traffic cop instantiates each
frame and shows it when required, and destroys it when completed. Luckily my
frames are all quite lightweight, so there does not seem to be much of an
overhead in doing it this way.

I had one interesting cosmetic problem to sort out. If the user moves a
child frame before closing it, they would expect the next one to come up in
the same position. I had to save the x/y position of each frame before
destroying it, and move the next one to the same position before showing it.
It looks fine now.

Many thanks again to all who assisted with this. I can continue developing
my application now :slight_smile:

Frank Millman

Hi Frank,
Thank you for the base program, i hope i can start with this one to get all
the things i want get started. python is a nice program but for me it is
still hard to see what is going on.

Stephan Huijgen

···

----- Original Message -----
From: "Chagford CC - Admin" <admin@chagford.com>
To: <wxPython-users@lists.wxwindows.org>
Sent: Friday, June 06, 2003 3:31 PM
Subject: Re: [wxPython-users] Dumb question

----- Original Message -----
From: "stephan huijgen" <s.huijgen@student.tudelft.nl>
To: <wxPython-users@lists.wxwindows.org>
Sent: Thursday, June 05, 2003 4:44 PM
Subject: RE: [wxPython-users] Dumb question

> Hi Frank,
> for my final thesis at the university i also want to make a panel with a
> login user id check and passwd check.
> can i get a copy of the program or otherwise some hints how to approach
> this..
> i am a super computer hero, so everything is bugging and debugging here
for
> me...
> it would help me a lot.
>
> regards,
>
> Stephan
>

With pleasure, Stephan.

In fact I will go one better, and attach the original program that was
kindly posted by someone a couple of months ago showing how to do this - I
can't remember your name, sorry, but thanks very much, it saved me quite a
bit of work.

I just store the name and password (encrypted, obviously) in a database,

and

compare them at login. I suppose you could encrypt the password again and
decrypt it at login time if you were really paranoid, but I have not
bothered with this.

Hope it helps.

Frank Millman

----------------------------------------------------------------------------
----

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org