Panel from XRC not 'activated' after loadPanel

After trying different angles of approach to attack this problem,
still no luck solving it. Anyone?

> My application retrieves XRC (XML) data from a server and loads a
> panel (xrc_panel) into a sizer of an existing (hardcoded) panel.
>
> mypanel(wx.Panel):
>
> def __init__(self, ...):
> self.main_sizer = wx.BoxSizer(wx.VERTICAL)
> ...
> self.init_xrc()
> self.Fit()
> self.main_sizer.SetSizeHints(self)
> self.main_sizer.Layout()
> self.Enable(True)
>
> def init_xrc(self):
> res = xrc.EmptyXmlResource()
> res.LoadFromString(resource_as_string)
> self.main_panel = res.LoadPanel(self, "main_panel")
> self.main_sizer.Add(self.main_panel,1,wx.EXPAND,0)
>
> The xrc_panel looks okay but none of the buttons can be clicked
> upon and no mouseover events are triggerd. First I need to klik
> somewhere on the xrc_panel and after that, the buttons and
> mouseover events work fine. Does anyone know how can I solve this
> problem?
>
> I've tried all kinds of SetFocus combinations to no avail.

Is the frame that the panel is in at the top of the z-order?

Setting frame.Raise() and SetFocus on the panel with the buttons
doesn't do much. Setting focus to one of the buttons, shows that the
button is focused, but mouse clicks still only work after clicking
(somewhere) on the panel itself.

Since all panels (and other widgets) are contained by sizers, it's
rather unlikely that there are overlapping child windows (which can
cause problems with focus according to various posts).

But it's not only the xrc_panel that doesn't 'work', the menubar and
buttons in other panels (that already existed) doesn't work either.
So it looks like some invisible panel is covering the application
stealing events.

···

On Wednesday 28 April 2004 05:37, Robin Dunn wrote:

Remy C. Cool wrote:

After trying different angles of approach to attack this problem, still no luck solving it. Anyone?

My application retrieves XRC (XML) data from a server and loads a
panel (xrc_panel) into a sizer of an existing (hardcoded) panel.

mypanel(wx.Panel):

def __init__(self, ...):
   self.main_sizer = wx.BoxSizer(wx.VERTICAL)
   ...
   self.init_xrc()
   self.Fit()
   self.main_sizer.SetSizeHints(self)
   self.main_sizer.Layout()
   self.Enable(True)

def init_xrc(self):
   res = xrc.EmptyXmlResource()
   res.LoadFromString(resource_as_string)
   self.main_panel = res.LoadPanel(self, "main_panel")
   self.main_sizer.Add(self.main_panel,1,wx.EXPAND,0)

The xrc_panel looks okay but none of the buttons can be clicked
upon and no mouseover events are triggerd. First I need to klik
somewhere on the xrc_panel and after that, the buttons and
mouseover events work fine. Does anyone know how can I solve this
problem?

I've tried all kinds of SetFocus combinations to no avail.

Is the frame that the panel is in at the top of the z-order?

Setting frame.Raise() and SetFocus on the panel with the buttons doesn't do much. Setting focus to one of the buttons, shows that the button is focused, but mouse clicks still only work after clicking (somewhere) on the panel itself.

Since all panels (and other widgets) are contained by sizers, it's rather unlikely that there are overlapping child windows (which can cause problems with focus according to various posts).

But it's not only the xrc_panel that doesn't 'work', the menubar and buttons in other panels (that already existed) doesn't work either. So it looks like some invisible panel is covering the application stealing events.

Please make a small sample that shows this problem. I have the feeling that it is probably something simple that will be obvious if I can play with some code.

···

On Wednesday 28 April 2004 05:37, Robin Dunn wrote:

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

I think I found the problem.
This is the bit of code wich loads an xrc_panel:

class popup_panel(base.controls.popup_toolbar):
    def on_button(self,button_name,evt):
        self.Hide()
        # call the switch function to activate the application
        app_panel.switch(button_name,evt)
  wx.Yield()

When the switch function is called the resourcefile is loaded.
Removing the Yield-function solves the problem and works just the same.

It's probably obvious, but I discovered it when trying to upgrade to
wxPython2.5 wich complained about nested Yields.

Thanks for your help.

···

On Wednesday 05 May 2004 19:18, Robin Dunn wrote:

Remy C. Cool wrote:
> After trying different angles of approach to attack this problem,
> still no luck solving it. Anyone?
>
> On Wednesday 28 April 2004 05:37, Robin Dunn wrote:
>>>My application retrieves XRC (XML) data from a server and loads a
>>>panel (xrc_panel) into a sizer of an existing (hardcoded) panel.
>>>
>>>mypanel(wx.Panel):
>>>
>>> def __init__(self, ...):
>>> self.main_sizer = wx.BoxSizer(wx.VERTICAL)
>>> ...
>>> self.init_xrc()
>>> self.Fit()
>>> self.main_sizer.SetSizeHints(self)
>>> self.main_sizer.Layout()
>>> self.Enable(True)
>>>
>>> def init_xrc(self):
>>> res = xrc.EmptyXmlResource()
>>> res.LoadFromString(resource_as_string)
>>> self.main_panel = res.LoadPanel(self, "main_panel")
>>> self.main_sizer.Add(self.main_panel,1,wx.EXPAND,0)
>>>
>>>The xrc_panel looks okay but none of the buttons can be clicked
>>>upon and no mouseover events are triggerd. First I need to klik
>>>somewhere on the xrc_panel and after that, the buttons and
>>>mouseover events work fine. Does anyone know how can I solve this
>>>problem?
>>>
>>>I've tried all kinds of SetFocus combinations to no avail.
>>
>>Is the frame that the panel is in at the top of the z-order?
>
> Setting frame.Raise() and SetFocus on the panel with the buttons
> doesn't do much. Setting focus to one of the buttons, shows that the
> button is focused, but mouse clicks still only work after clicking
> (somewhere) on the panel itself.
>
> Since all panels (and other widgets) are contained by sizers, it's
> rather unlikely that there are overlapping child windows (which can
> cause problems with focus according to various posts).
>
> But it's not only the xrc_panel that doesn't 'work', the menubar and
> buttons in other panels (that already existed) doesn't work either.
> So it looks like some invisible panel is covering the application
> stealing events.

Please make a small sample that shows this problem. I have the feeling
that it is probably something simple that will be obvious if I can play
with some code.