@@ -39,24 +39,23 @@ def append(self, item):
3939
4040 self .__contents .append (item )
4141 item .parent = self
42+ self .elem_changed ()
4243
43- self .__elem_changed ()
44-
45- def __elem_changed (self ):
44+ def elem_changed (self ):
4645 # Ensure that this group is what the board is currently showing.
4746 # Otherwise, don't bother to draw it.
48- if (
49- self .__auto_write
50- and self .__check_active_group_ref
51- and board .DISPLAY .active_group == self
52- ):
47+ if self .__auto_write :
48+ self .trigger_draw ()
49+
50+ def trigger_draw (self ):
51+ # select the correct parent to draw from if necessary
52+ if self .__check_active_group_ref and board .DISPLAY .active_group == self :
5353 self .draw ()
5454
5555 elif self .in_group :
56-
5756 # If a sub-group is modified, propagate to top level to
5857 # see if one of the parents are the current active group.
59- self .parent .__elem_changed ()
58+ self .parent .elem_changed ()
6059
6160 def __getitem__ (self , index ):
6261 return self .__contents [index ]
@@ -65,9 +64,8 @@ def __setitem__(self, index, val):
6564 old_val = self .__contents [index ]
6665
6766 self .__contents [index ] = val
68-
6967 if old_val != val :
70- self .__elem_changed ()
68+ self .elem_changed ()
7169
7270 def draw (self , img = None , x = 0 , y = 0 , scale = None , show = True ):
7371 # this function is not a part of the orignal implementation
@@ -142,5 +140,5 @@ def __len__(self):
142140 def pop (self , i = - 1 ):
143141 item = self .__contents .pop (i )
144142 item .parent = None
145- self .__elem_changed ()
143+ self .elem_changed ()
146144 return item
0 commit comments