Browse Source

implementing get_size and get_position for proxy

Rodja Trappe 2 years ago
parent
commit
f03f35c2ee
2 changed files with 12 additions and 0 deletions
  1. 6 0
      nicegui/native.py
  2. 6 0
      nicegui/native_mode.py

+ 6 - 0
nicegui/native.py

@@ -19,6 +19,12 @@ class WindowProxy(webview.Window):
     def __init__(self):
         pass  # NOTE we don't call super().__init__ here because this is just a proxy to the actual window
 
+    async def get_size(self) -> Tuple[int, int]:
+        return await self._send_async()
+
+    async def get_position(self) -> Tuple[int, int]:
+        return await self._send_async()
+
     def load_url(self, url: str) -> None:
         self._send(url)
 

+ 6 - 0
nicegui/native_mode.py

@@ -48,6 +48,12 @@ def start_window_method_executor(
         while not closing.is_set():
             try:
                 method, args, kwargs = method_queue.get(block=False)
+                if method == 'get_position':
+                    response_queue.put((int(window.x), int(window.y)))
+                    continue
+                if method == 'get_size':
+                    response_queue.put((int(window.width), int(window.height)))
+                    continue
                 attr = getattr(window, method)
                 if callable(attr):
                     response = attr(*args, **kwargs)