Maybe I haven't completely thought this through, is it possible to have
a dialog that is modal only in relationship to a given frame in a
multi-frame application.
For example, say the user clicks on a 'process' button and the result of
the processing needs to display a message dialog. They way I might do
this is to write the processing code in direct response to the button
click. This code would not return until the user dismisses the dialog.
However, at this point the event loop is not sending events to other
application frames, so they are 'dead' as far as the user is concerned.
What I'd like to do is have the frame that launched the processing
appear 'dead', but have other application frames still active. Until the
user dismisses the dialog, the frame that launched the process is
'dead', but the user can freely interact with other frames.
Where I see a need for this would be if the dialog asked the user a
question for which the user needed to lookup other information in
another frame of the application.
What I’d like to do is have the frame that launched the processing
appear ‘dead’, but have other application frames still active. Until the
user dismisses the dialog, the frame that launched the process is
‘dead’, but the user can freely interact with other frames.
I don’t believe you can do that via standard “modal” behavior of having a ‘ShowModal()’ block until this new frame is done, but in the one situation where I needed something like that, it wasn’t too hard to simulate.
Basically, the first part of the strategy I used to use the wx.FRAME_FLOAT_ON_PARENT style in the pseudo-model dialog.
The display method became ‘.Show(callback=self._ReceiveAnswer)’
I made sure to center that dialog over said parent when it was launched.
On it’s launch, I call “.Enable(False)” on the parent of the pseudo-modal dialog.
When it was ready to return a result, I’d call “.Enable(True)” on the parent
I’d then call the callback specified on .Show, pass it the results, and close the pseudo-modal dialog.
There might be an easier way, but the above is actually pretty easy.
On Sun, 2007-12-02 at 23:48 -0800, Stephen Hansen wrote:
What I'd like to do is have the frame that launched the
processing
appear 'dead', but have other application frames still active.
Until the
user dismisses the dialog, the frame that launched the process
is
'dead', but the user can freely interact with other frames.
I don't *believe* you can do that via standard "modal" behavior of
having a 'ShowModal()' block until this new frame is done, but in the
one situation where I needed something like that, it wasn't too hard
to simulate.
* Basically, the first part of the strategy I used to use the
wx.FRAME_FLOAT_ON_PARENT style in the pseudo-model dialog.
* The display method became '.Show(callback=self._ReceiveAnswer)'
* I made sure to center that dialog over said parent when it was
launched.
* On it's launch, I call ".Enable(False)" on the parent of the
pseudo-modal dialog.
* When it was ready to return a result, I'd call ".Enable(True)" on
the parent
* I'd then call the callback specified on .Show, pass it the results,
and close the pseudo-modal dialog.
There might be an easier way, but the above is actually pretty easy.
Maybe I haven't completely thought this through, is it possible to have
a dialog that is modal only in relationship to a given frame in a
multi-frame application.
For example, say the user clicks on a 'process' button and the result of
the processing needs to display a message dialog. They way I might do
this is to write the processing code in direct response to the button
click. This code would not return until the user dismisses the dialog.
However, at this point the event loop is not sending events to other
application frames, so they are 'dead' as far as the user is concerned.
What I'd like to do is have the frame that launched the processing
appear 'dead', but have other application frames still active. Until the
user dismisses the dialog, the frame that launched the process is
'dead', but the user can freely interact with other frames.
Where I see a need for this would be if the dialog asked the user a
question for which the user needed to lookup other information in
another frame of the application.
To phrase it a different way, you are looking for a way to make dialogs be parent-modal instead of app-modal. This has been discussed in the past, and we may eventually get support for that from wxWidgets, but currently it can only reliably do app-modal dialogs. Stephen's suggestion sounds like a reasonable alternative though. Perhaps we can twist his arm a bit so he will make a recipe page in the wiki for it? (hint, hint)
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!