Pārlūkot izejas kodu

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

Falko Schindler 2 gadi atpakaļ
vecāks
revīzija
203a3dea89
1 mainītis faili ar 4 papildinājumiem un 0 dzēšanām
  1. 4 0
      nicegui/elements/element.py

+ 4 - 0
nicegui/elements/element.py

@@ -30,6 +30,10 @@ class Element:
 
         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):
         bind_to(self, 'visible', target_object, target_name, forward=forward)
         return self