Explorar o código

update parent element when adding element to main page (without entering/exiting a context)

Falko Schindler %!s(int64=2) %!d(string=hai) anos
pai
achega
203a3dea89
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      nicegui/elements/element.py

+ 4 - 0
nicegui/elements/element.py

@@ -30,6 +30,10 @@ class Element:
 
 
         self.visible = True
         self.visible = True
 
 
+        if len(view_stack) == 1 and asyncio.get_event_loop().is_running():
+            # NOTE: This is the main page. There won't be any context exit and thus no UI update. So let's do that here.
+            create_task(self.parent_view.update())
+
     def bind_visibility_to(self, target_object, target_name, forward=lambda x: x):
     def bind_visibility_to(self, target_object, target_name, forward=lambda x: x):
         bind_to(self, 'visible', target_object, target_name, forward=forward)
         bind_to(self, 'visible', target_object, target_name, forward=forward)
         return self
         return self