calling wxInitializeStockObjects early
Alex Fenton
alex at deleteme.pressure.to
Fri Jan 5 02:02:35 PST 2007
Robin Dunn wrote:
> 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.
Thanks, that looks an interesting approach. In Ruby it's not a problem for the interpreter to see a constant it doesn't know about within a method definition (eg as a default arg), so long as it can resolve it when the expression is evaluated, which is guaranteed to be after the App is init'd.
Unfortunately I was hoping I could also continue to use code like
class HighlightingTextCtrl < Wx::TextCtrl
HIGHLIGHT = Wx::TextAttr.new(Wx::BLACK, Wx::YELLOW,
Wx::SWISS_FONT)
def do_highlight(start, end)
set_style(start, end, HIGHLIGHT)
end
Here the TextAttr.new is evaluated as the class is being defined, which is before an App has started. So it needs real values for the colours and fonts at that time.
PS - should say a big thanks to you and wxPython team - it's a great piece of work - the source and samples have been a place for us to turn in dark times of SWIG ...
alex
More information about the wx-users
mailing list