Modal and return - tricky thing

Hi,

I'm having a little problem here I can't find an answer to.
I have a modal dialog (wx.Dialog derived class). Normally one would call the
ShowModal either in the constructor, or have a function wrapper actually call
it (better solution).
Anyways - with this dialog I have to wait for some things to happen before I
actually can call the ShowModal. If I call it earlier the dialog for the one
part doesn't have all the controls it needs (I load panels into a tabsizer
depending on a database query that is quite expensive and takes a while) and
the worst is, that the moment the ShowModal is called also the
TransferToWindow is called which at that incomplete point of initialization
simply creates errors.
My problem is to wait for the things to happen, without returning control to
the caller. Has anyone an idea how I could "block" the caller until I can
actually call ShowModal ? Really blocking (using a while loop or so) is not
an option, since as said before some things are happening and then they would
block too.

Personally I'd like to do something like a "ShowModal(dontShow=True)", so the
Dialog is actually in it's modal state, but doesn't show on the screen yet
and also doesn't call the TransferToWindow yet, let say until I call
something like "dialog.UnHide()"

I currently have it working, but the caller simply goes on and is not blocked.
I just call the ShowModal some time down the road when the init has finished.
However it would be great to have the caller wait for the dialog to close.

Any ideas anyone ?

(No I'm not going to rewrite it completely. It took me days to assemble it.
It's actually constructing itself by downloading xrc and .pyc modules from
the server depending on a lot of parameters. This makes it possible for me to
change the dialog by simply reconfiguring some records in the database)

  UC

- --
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

Uwe C. Schroeder wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm having a little problem here I can't find an answer to.
I have a modal dialog (wx.Dialog derived class). Normally one would call the ShowModal either in the constructor, or have a function wrapper actually call it (better solution).
Anyways - with this dialog I have to wait for some things to happen before I actually can call the ShowModal. If I call it earlier the dialog for the one part doesn't have all the controls it needs (I load panels into a tabsizer depending on a database query that is quite expensive and takes a while) and the worst is, that the moment the ShowModal is called also the TransferToWindow is called which at that incomplete point of initialization simply creates errors.
My problem is to wait for the things to happen, without returning control to the caller. Has anyone an idea how I could "block" the caller until I can actually call ShowModal ? Really blocking (using a while loop or so) is not an option, since as said before some things are happening and then they would block too.

Personally I'd like to do something like a "ShowModal(dontShow=True)", so the Dialog is actually in it's modal state, but doesn't show on the screen yet and also doesn't call the TransferToWindow yet, let say until I call something like "dialog.UnHide()"

I currently have it working, but the caller simply goes on and is not blocked. I just call the ShowModal some time down the road when the init has finished.
However it would be great to have the caller wait for the dialog to close.

Any ideas anyone ?

I think I would use a wxProgressDialog and update its progress bar while loading all the stuff, and then when it is all loaded dismiss the progress dialog and call ShowModal at that time.

···

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