Hello,
I’m creating a dialog box “waiting” for an external trigger, before closing/destroying itself.
When using :
waitingdlg = wx.MessageDialog( … )
waitingdlg.ShowModal()
I notice that I cannot destroy it from an external thread with waitingdlg.Destroy(). Why ?
If so, it seems that I should redo all with a wx.Dialog : information icon, white background on the upper part of the dialog, grey background on the lower part of the dialog, main text, main buttons, bind buttons, etc. Moreover this will break the native look of the OS on some platforms…
I would really like to keep a standard wx.MessageDialog (standard OS look), but I also need to be able to destroy it from an external thread.
Hello,
I'm creating a dialog box "waiting" for an external trigger, before closing/destroying itself.
When using :
waitingdlg = wx.MessageDialog( ... )
waitingdlg.ShowModal()
I notice that I cannot destroy it from an external thread with waitingdlg.Destroy(). Why ?
If so, it seems that I should redo all with a wx.Dialog : information icon, white background on the upper part of the dialog, grey background on the lower part of the dialog, main text, main buttons, bind buttons, etc. Moreover this will break the native look of the OS on some platforms...
I would really like to keep a standard wx.MessageDialog (standard OS look), but I also need to be able to destroy it from an external thread.
I notice that I cannot destroy it from an external thread with waitingdlg.Destroy(). Why ?
If so, it seems that I should redo all with a wx.Dialog : information icon, white background on the upper part of the dialog, grey background on the lower part of the dialog, main text, main buttons, bind buttons, etc. Moreover this will break the native look of the OS on some platforms…
I would really like to keep a standard wx.MessageDialog (standard OS look), but I also need to be able to destroy it from an external thread.
Any idea about this?
Not using threads but from what I read here you need to use wx.CallAfter, see e.g.:
Hello,
I'm creating a dialog box "waiting" for an external trigger, before
closing/destroying itself.
When using :
waitingdlg = wx.MessageDialog( ... )
waitingdlg.ShowModal()
I notice that I cannot destroy it from an external thread with
waitingdlg.Destroy(). Why ?
This is an operating system limitation. Even from C++, there is no
(documented) method of forcing a modal message box to close.
(If you can get the window handle, you can send it a WM_CLOSE message,
but that's icky and system-dependent.)
If so, it seems that I should redo all with a wx.Dialog : information
icon, white background on the upper part of the dialog, grey
background on the lower part of the dialog, main text, main buttons,
bind buttons, etc. Moreover this will break the native look of the OS
on some platforms...
Yes, but that's OK, because you are breaking the native BEHAVIOR as well.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
This is an operating system limitation. Even from C++, there is no
(documented) method of forcing a modal message box to close.
(If you can get the window handle, you can send it a WM_CLOSE message,
but that's icky and system-dependent.)
Ok thank you, now I know the reason.
> If so, it seems that I should redo all with a wx.Dialog : information
> icon, white background on the upper part of the dialog, grey
> background on the lower part of the dialog, main text, main buttons,
> bind buttons, etc. Moreover this will break the native look of the OS
> on some platforms...
Yes, but that's OK, because you are breaking the native BEHAVIOR as well.
> Robin Dunn :
> The wx.MessageDialog is not a real wx.Dialog, it's just a convenience
> wrapper around a native API function. As such it does not implement
> most of the wx.Dialog API.
> To do what you want you'll need to either create your own message dialog
> class or use something like wx.lib.agw.genericmessagedialog.
--
A last question : Robin, do you think it would be possible to add
handling of Destroy() to the *standard* wx.MessageDialog (to be sure to
keep the native OS look) ?
No, but even if it was possible Destroy is not what you want to be using for this anyway. You should use EndModal for modal dialogs (and this will work with generic wx.Dialogs). EndModal does just what it says it does, end the modality and cause ShowModal to return, and the advantage is that the dialog still exists so the code that called ShowModal can read values from it, and then it will call Destroy from there like usual.