I have a quick question about hooking the event wx.EVT_INIT_DIALOG.
The online docs seem to mention that this event can be hooked by a
wxPanel. So I tried that with the following bind statement but to no
avail. My problem is that I am trying to initialize the panel with
data & need to resize some ctrls on it & ask for a ctrls width, but it
comes back as zero since the panel isn't shown yet. What's the best
way to know when the panel is shown?
class MyPanel(wx.Panel):
def __init__(self):
self.Bind(wx.EVT_INIT_DIALOG, self.OnInitDialog)
I have a quick question about hooking the event wx.EVT_INIT_DIALOG.
The online docs seem to mention that this event can be hooked by a
wxPanel. So I tried that with the following bind statement but to no
avail. My problem is that I am trying to initialize the panel with
data & need to resize some ctrls on it & ask for a ctrls width, but it
comes back as zero since the panel isn't shown yet. What's the best
way to know when the panel is shown?
class MyPanel(wx.Panel):
def __init__(self):
self.Bind(wx.EVT_INIT_DIALOG, self.OnInitDialog)
I have a quick question about hooking the event wx.EVT_INIT_DIALOG.
The online docs seem to mention that this event can be hooked by a
wxPanel. So I tried that with the following bind statement but to no
avail. My problem is that I am trying to initialize the panel with
data & need to resize some ctrls on it & ask for a ctrls width, but it
comes back as zero since the panel isn't shown yet. What's the best
way to know when the panel is shown?
class MyPanel(wx.Panel):
def __init__(self):
self.Bind(wx.EVT_INIT_DIALOG, self.OnInitDialog)
IIRC the EVT_INIT_DIALOG event is only sent automatically to dialogs. To use it on a panel you need to call the InitDialog method yourself, which in this case really doesn't buy you anything since you can just as easily call some method that does what you are trying to do in the event handler instead.
What are you really needing? A panel is shown by default when it is created, but its parent top level window may not be shown yet, so catching the panel's EVT_SHOW won't help. You mention sizes, do you just want to know when the size changes? EVT_SIZE will help you do that, but if you use a sizer then be careful to not block the default size handler from doing the sizer layout. If you just need to do something once after the panel has been created and after the current pending events (like showing and sizing the window) have been completed then use wx.CallAfter to invoke your function at the next idle event.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
What I am trying to do is size the columns of a list control, which
happens to be in a panel based on the width of the panel. If I
perform the calculations before the panel is shown I get a width size
of zero. What's the correct handler to use to size the columns of a
list control.
Thanks.
Steve
···
On Wed, Dec 31, 2008 at 2:41 AM, Robin Dunn <robin@alldunn.com> wrote:
Stephen Burke wrote:
I have a quick question about hooking the event wx.EVT_INIT_DIALOG.
The online docs seem to mention that this event can be hooked by a
wxPanel. So I tried that with the following bind statement but to no
avail. My problem is that I am trying to initialize the panel with
data & need to resize some ctrls on it & ask for a ctrls width, but it
comes back as zero since the panel isn't shown yet. What's the best
way to know when the panel is shown?
class MyPanel(wx.Panel):
def __init__(self):
self.Bind(wx.EVT_INIT_DIALOG, self.OnInitDialog)
IIRC the EVT_INIT_DIALOG event is only sent automatically to dialogs. To use it on a panel you need to call the InitDialog method yourself, which in this case really doesn't buy you anything since you can just as easily call some method that does what you are trying to do in the event handler instead.
What are you really needing? A panel is shown by default when it is created, but its parent top level window may not be shown yet, so catching the panel's EVT_SHOW won't help. You mention sizes, do you just want to know when the size changes? EVT_SIZE will help you do that, but if you use a sizer then be careful to not block the default size handler from doing the sizer layout. If you just need to do something once after the panel has been created and after the current pending events (like showing and sizing the window) have been completed then use wx.CallAfter to invoke your function at the next idle event.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
What I am trying to do is size the columns of a list control, which
happens to be in a panel based on the width of the panel. If I
perform the calculations before the panel is shown I get a width size
of zero. What's the correct handler to use to size the columns of a
list control.
Probably EVT_SIZE. See the wx.lib.mixins.listctrl.ListCtrlAutoWidthMixin class for an example, or you may be able to use it directly.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!