calling wxInitializeStockObjects early
Robin Dunn
robin at alldunn.com
Thu Jan 4 14:42:22 PST 2007
Alex Fenton wrote:
> The need for this is in wxRuby. We want constants such as Wx::RED,
> Wx::NULL_BITMAP (which correspond to wx stock objects) to be available
> as soon as the ruby library (wxruby2.so) is loaded, which is before
> we're able to create in C++ the instance of wxRubyApp that will actually
> be run.
I don't know if Ruby will let you do the same thing, but in wxPython 2.8
I'm now dealing with the stock objects by first creating an
uninitialized instance of the Python object when the module is imported.
Then later, when the app object has been created, the wrappers call a
function that initializes those instances using the wxStockGDI class.
It looks something like this:
# Python code executed upon import
RED = Colour.__new__(Colour)
# Python code called from the wx.App init code
wx.RED.this = wx.StockGDI.GetColour(wx.StockGDI.COLOUR_RED).this
So this way the wx.RED instance is created at import, and can be used
for default values, etc. Then when the app is created that same
instance's .this attribute is set to the real C++ colour instance and
then wx.RED (and any other variables that have been initialized to
wx.RED) can be used as a wx.Colour.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wx-users
mailing list