File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -190,8 +190,13 @@ def _update_background_color(self, new_color):
190190 )
191191 lines = self .text .count ("\n " ) + 1
192192 if not self ._added_background_tilegrid :
193- self ._added_background_tilegrid = True
194- self .insert (0 , self ._create_background_box (lines , y_offset ))
193+ # only if we have text or padding
194+ if len (self .text ) + self ._padding_left + self ._padding_right > 0 :
195+ if len (self ) > 0 :
196+ self .insert (0 , self ._create_background_box (lines , y_offset ))
197+ else :
198+ self .append (self ._create_background_box (lines , y_offset ))
199+ self ._added_background_tilegrid = True
195200 else :
196201 self [0 ] = self ._create_background_box (lines , y_offset )
197202
@@ -294,6 +299,11 @@ def _update_text(
294299 self .insert (0 , self ._create_background_box (lines , y_offset ))
295300 else :
296301 self [0 ] = self ._create_background_box (lines , y_offset )
302+ else :
303+ self ._background_palette .make_transparent (0 )
304+ if self ._added_background_tilegrid :
305+ self .pop (0 )
306+ self ._added_background_tilegrid = False
297307
298308 @property
299309 def bounding_box (self ):
You can’t perform that action at this time.
0 commit comments