There's something that I can't figure out how to do.
I have a dialog, and I want to center it on its top level parent. That
is, if the dialog was spawned from frame `f`, I want it to be centered
on frame `f`. If it was spawned from a widget inside a widget inside a
widget inside frame `f`, I want it to center on frame `f`. If it was
spawned from a dialog `d`, I want it to center on dialog `d`. If it
was spawned from a widget inside a widget inside a widget inside
dialog `d`, I want it to center on dialog `d`.
I haven't been able to do that because I notice that sometimes dialogs
have a parent and sometimes they don't, and I can't figure out why.
For example I have a dialog, subclass of `wx.MessageDialog`, that is
constructed with a parent but when I do `GetParent` I get `None`.
I searched for docs about this but couldn't find any, neither for
wxPython nor wxWidgets.
There's something that I can't figure out how to do.
I have a dialog, and I want to center it on its top level parent. That
is, if the dialog was spawned from frame `f`, I want it to be centered
on frame `f`. If it was spawned from a widget inside a widget inside a
widget inside frame `f`, I want it to center on frame `f`. If it was
spawned from a dialog `d`, I want it to center on dialog `d`. If it
was spawned from a widget inside a widget inside a widget inside
dialog `d`, I want it to center on dialog `d`.
GetTopLevelParent will get you the top level window above the window it is called on, if there is one.
I haven't been able to do that because I notice that sometimes dialogs
have a parent and sometimes they don't, and I can't figure out why.
For example I have a dialog, subclass of `wx.MessageDialog`, that is
constructed with a parent but when I do `GetParent` I get `None`.
wx.MessageDialog is not a real wx.Dialog (it's just a wrapper around a platform API function) so you can't expect anything to work other than setting the content and showing the dialog.
How do I solve this?
Use a generic or your own custom dialog for showing messages.
There’s something that I can’t figure out how to do.
I have a dialog, and I want to center it on its top level parent. That
is, if the dialog was spawned from frame f, I want it to be centered
on frame f. If it was spawned from a widget inside a widget inside a
widget inside frame f, I want it to center on frame f. If it was
spawned from a dialog d, I want it to center on dialog d. If it
was spawned from a widget inside a widget inside a widget inside
dialog d, I want it to center on dialog d.
GetTopLevelParent will get you the top level window above the window it is called on, if there is one.
I haven’t been able to do that because I notice that sometimes dialogs
have a parent and sometimes they don’t, and I can’t figure out why.
For example I have a dialog, subclass of wx.MessageDialog, that is
constructed with a parent but when I do GetParent I get None.
wx.MessageDialog is not a real wx.Dialog (it’s just a wrapper around a platform API function) so you can’t expect anything to work other than setting the content and showing the dialog.
Will .Centre() work on this kind of bogus dialog?
How do I solve this?
Use a generic or your own custom dialog for showing messages.
–
Robin Dunn
Ram.
···
On Sat, Oct 30, 2010 at 1:16 AM, Robin Dunn robin@alldunn.com wrote:
You might want to look at GenericMessageDialog by Andrea Gavana, which
is in the Demo. It's pure Python and a true dialog, so you can do
whatever you want with it in terms of centering on its parent, etc.
Che
···
On Sat, Oct 30, 2010 at 5:58 AM, cool-RR <cool-rr@cool-rr.com> wrote:
On Sat, Oct 30, 2010 at 1:52 AM, Robin Dunn <robin@alldunn.com> wrote:
On 10/29/10 4:49 PM, cool-RR wrote:
On Sat, Oct 30, 2010 at 1:16 AM, Robin Dunn <robin@alldunn.com
wx.MessageDialog is not a real wx.Dialog (it's just a wrapper around
a platform API function) so you can't expect anything to work other
than setting the content and showing the dialog.
Will `.Centre()` work on this kind of bogus dialog?
No.
--
Robin Dunn
Thanks!
I think that my solution will be to always give my dialogs a parent which is
a top-level widget.