I have made a small app with a GUI in python using the wxpython toolkit. It consists of a frame as the top window and 100 StaticText child widgets. I have bind their size events (wx.EVT_SIZE) to a OnResize function which changes their font according to the size of the StaticText widgets. (This helps to increase or decrease the size of the font of the widgets when I resize my frame window accordingly at runtime.)
Now the poblem is that the OnResize function gets called 4 times every time I resize my frame. This considerably slowsdown the startup of my app (and also its resizing.) What I want is that the OnResize function must get called only once.
Is this possible in any way?
Consider an alternative approach.
Keep a variable of the previously processed size. Then, in your size handler, only change the font size if the size of the widget actually changed since the last size event.
def OnResize(self, event):
w, h = size = self.GetSize()
if size != self.previous_size:
# update font size
self.previous_size = size
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With