xrc and WINDOW_CREATE event

Dear list,

I'd like to know how you are handling the two step creation process when using
own derived controls with xrc.
At least on wxGTK in some cases the creation of the window is delayed until is
becomes visible, e.g. a panel sitting on a notebook page. This means that you
can't access attributes which are set up in the WINDOW_CREATE evt handler before
the user makes that window visible. Therefore I just dropped waiting for the
event and called the handler by hand directly after self.PostCreate(obj). I was
lucky that it worked for my app which heavily uses xrc both on linux and
windows. Now however, while building test cases for the custom xrc based
controls, i.e. a small test application which opens a frame holding that
control, I encountered problems with that method, more precisely the test app
segfaults. This happens on the code right after PostCreate, so this is obviously
due to not waiting for the WINDOW_CREATE event.
So the question to those who are using xrc out there: how do you handle that issue?

Christian

I personally don't use XRC, but one method of handling this particular
issue is through the use of a MVC approach. Your XRC is the View, the
Python you write to handle events, etc., is the Controller, now you just
need to create a Model and use something like wx.lib.pubsub to handle
the propagation of data between your Model and View.

- Josiah

···

Christian <ckkart@hoc.net> wrote:

So the question to those who are using xrc out there: how do you
handle that issue?

Josiah Carlson wrote:

So the question to those who are using xrc out there: how do you
handle that issue?

I personally don't use XRC, but one method of handling this particular
issue is through the use of a MVC approach. Your XRC is the View, the
Python you write to handle events, etc., is the Controller, now you just
need to create a Model and use something like wx.lib.pubsub to handle
the propagation of data between your Model and View.

I'm already using a pattern similar to what you're proposing but I don't see how
this could solve my problem.
Imagine a notebook page which contains a custom class derived from wx.Panel. In
the post creation code a wx.Grid is attached to the panel. This however happens
only after the page became visible. Thus the controller cannot e.g. set the grid
data whenever it wants to but only after the grid was actually created.

Christian

···

Christian <ckkart@hoc.net> wrote:

Using wx.lib.pubsub, the receiver for the data in the model isn't
subscribed until the post-create code is executed. At the point of
creation, it fetches the data from the model to display.

Alternatively, try to set the data in the grid, and when you fail,
ignore the failure. Later when the page is actually created, fetch the
data and display it.

- Josiah

···

Christian <ckkart@hoc.net> wrote:

Josiah Carlson wrote:
> Christian <ckkart@hoc.net> wrote:
>> So the question to those who are using xrc out there: how do you
>> handle that issue?
>
> I personally don't use XRC, but one method of handling this particular
> issue is through the use of a MVC approach. Your XRC is the View, the
> Python you write to handle events, etc., is the Controller, now you just
> need to create a Model and use something like wx.lib.pubsub to handle
> the propagation of data between your Model and View.

I'm already using a pattern similar to what you're proposing but I don't see how
this could solve my problem.
Imagine a notebook page which contains a custom class derived from wx.Panel. In
the post creation code a wx.Grid is attached to the panel. This however happens
only after the page became visible. Thus the controller cannot e.g. set the grid
data whenever it wants to but only after the grid was actually created.