I'm rewriting wx.lib.analogclock to give it a cleaner code,
anti-aliasing features, a couple of extra styles, follow the new
wxPython Coding Guidelines, etc. While at that, I noticed that
AnalogClock is derived of wx.PyWindow, what leads me to some
questions: what are the main differences between wx.PyWindow and
wx.Window, or when is the right time to use wx.PyWindow or wx.Window?
Also, on the AnalogClock's __init__ method there is the following
fragment of code. I (think I) can understand what it does, but is it
really needed?
...
size = wx.Size(*size)
bestSize = self.GetBestSize()
size.x = max(size.x, bestSize.x)
size.y = max(size.y, bestSize.y)
self.SetSize(size)
...
Thanks in advance,
-- tacao
No bits were harmed during the making of this e-mail.
Friday, January 13, 2006, 5:48:01 PM, Robin Dunn wrote:
E. A. Tacao wrote:
I'm rewriting wx.lib.analogclock to give it a cleaner code,
anti-aliasing features, a couple of extra styles, follow the new
wxPython Coding Guidelines, etc. While at that, I noticed that
AnalogClock is derived of wx.PyWindow, what leads me to some
questions: what are the main differences between wx.PyWindow and
wx.Window, or when is the right time to use wx.PyWindow or
wx.Window?
wx.PyWindow is instrumented to all some of the V++ virtual methods
to be overridden in Python derived classes, and have the Python
method be called when the method is called from C++.
AnalogClockWindow it is currently overriding DoGetBestSize which is
called by the sizers to determine what size the window would like to
have reserved for it. Since AnalogClockWindow.DoGetBestSize is just
returned a fixed size you could probably get by with just setting
the min size to that fixed size instead, but if you ever want to be
able to calculate a best size based on other factors (such as clock
display options that are turned on, etc.) then you'll want to be
able to do it on the fly from DoGetBestSize.
Also, on the AnalogClock's __init__ method there is the following
fragment of code. I (think I) can understand what it does, but is
it really needed?
...
size = wx.Size(*size)
bestSize = self.GetBestSize()
size.x = max(size.x, bestSize.x)
size.y = max(size.y, bestSize.y)
self.SetSize(size)
...
That would be almost equivalent to this:
self.SetBestFittingSize(size)
The "almost" above is only because the size object will not be updated
in this case.
Thanks. It's seems that it's safe and simpler to use a wx.Window
instead for the AnalogClock since I'm not overriding any wx.Window
method, and also let it decide what's the best size.
-- tacao
No bits were harmed during the making of this e-mail.