[wxPython-users] Re: xrc and WINDOW_CREATE event

Josiah Carlson jcarlson at uci.edu
Wed Mar 28 22:49:09 PDT 2007


Christian <ckkart at hoc.net> wrote:
> 
> Josiah Carlson wrote:
> > Christian <ckkart at 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.

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





More information about the wxpython-users mailing list