@@ -193,6 +193,7 @@ class WButtonGroup( WObject ):
193
193
def __init__ (self , exclusive = True , * args , ** kw ):
194
194
super (WButtonGroup , self ).__init__ (* args , ** kw )
195
195
self ._exclusive = exclusive
196
+ self ._dirty = False
196
197
197
198
def on_mouse_click_proxy ( self , widget , x , y , buttons , modifiers ):
198
199
@@ -208,22 +209,36 @@ def on_mouse_click_proxy( self, widget, x, y, buttons, modifiers):
208
209
w .checked = False
209
210
w .on_toggle ()
210
211
212
+ def add ( self , * args , ** kw ):
213
+ self ._dirty = True
214
+ super ( WButtonGroup , self ).add ( * args , ** kw )
215
+
211
216
def on_mouse_click ( self , x , y , buttons , modifiers ):
212
217
# ignore
213
218
pass
214
219
215
220
def _get_width ( self ):
216
- w = 0
217
- for z ,widget in self .children :
218
- x ,y = widget .position
219
- w = max (w ,x + widget .width )
220
- return w
221
+ if self ._dirty :
222
+ h = w = 0
223
+ for z ,widget in self .children :
224
+ x ,y = widget .position
225
+ w = max (w ,x + widget .width )
226
+ h = max (h ,y + widget .height )
227
+ self ._dirty = False
228
+ self ._width = w
229
+ self ._height = h
230
+ return self ._width
221
231
def _get_height ( self ):
222
- h = 0
223
- for z ,widget in self .children :
224
- x ,y = widget .position
225
- h = max (h ,y + widget .height )
226
- return h
232
+ if self ._dirty :
233
+ h = w = 0
234
+ for z ,widget in self .children :
235
+ x ,y = widget .position
236
+ w = max (w ,x + widget .width )
237
+ h = max (h ,y + widget .height )
238
+ self ._dirty = False
239
+ self ._width = w
240
+ self ._height = h
241
+ return self ._height
227
242
228
243
def _get_exclusive ( self ):
229
244
return self ._exclusive
0 commit comments