瀏覽代碼

added frameless parameter and changed exception catch

smug 1 年之前
父節點
當前提交
d62eb74add
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      nicegui/native_mode.py

+ 6 - 5
nicegui/native_mode.py

@@ -25,13 +25,14 @@ except ModuleNotFoundError:
 
 
 
 
 def open_window(
 def open_window(
-    host: str, port: int, title: str, width: int, height: int, fullscreen: bool,
+    host: str, port: int, title: str, width: int, height: int, fullscreen: bool, frameless: bool,
     method_queue: mp.Queue, response_queue: mp.Queue,
     method_queue: mp.Queue, response_queue: mp.Queue,
 ) -> None:
 ) -> None:
     while not helpers.is_port_open(host, port):
     while not helpers.is_port_open(host, port):
         time.sleep(0.1)
         time.sleep(0.1)
 
 
-    window_kwargs = dict(url=f'http://{host}:{port}', title=title, width=width, height=height, fullscreen=fullscreen)
+    window_kwargs = dict(url=f'http://{host}:{port}', title=title, width=width,
+                         height=height, fullscreen=fullscreen, frameless=frameless)
     window_kwargs.update(globals.app.native.window_args)
     window_kwargs.update(globals.app.native.window_args)
 
 
     try:
     try:
@@ -40,7 +41,7 @@ def open_window(
         window.events.closing += closing.set
         window.events.closing += closing.set
         start_window_method_executor(window, method_queue, response_queue, closing)
         start_window_method_executor(window, method_queue, response_queue, closing)
         webview.start(storage_path=tempfile.mkdtemp(), **globals.app.native.start_args)
         webview.start(storage_path=tempfile.mkdtemp(), **globals.app.native.start_args)
-    except NameError:
+    except AttributeError:
         logging.error('''Native mode is not supported in this configuration.
         logging.error('''Native mode is not supported in this configuration.
 Please run "pip install pywebview" to use it.''')
 Please run "pip install pywebview" to use it.''')
         sys.exit(1)
         sys.exit(1)
@@ -90,7 +91,7 @@ def start_window_method_executor(
     Thread(target=window_method_executor).start()
     Thread(target=window_method_executor).start()
 
 
 
 
-def activate(host: str, port: int, title: str, width: int, height: int, fullscreen: bool) -> None:
+def activate(host: str, port: int, title: str, width: int, height: int, fullscreen: bool, frameless: bool) -> None:
     def check_shutdown() -> None:
     def check_shutdown() -> None:
         while process.is_alive():
         while process.is_alive():
             time.sleep(0.1)
             time.sleep(0.1)
@@ -100,7 +101,7 @@ def activate(host: str, port: int, title: str, width: int, height: int, fullscre
         _thread.interrupt_main()
         _thread.interrupt_main()
 
 
     mp.freeze_support()
     mp.freeze_support()
-    args = host, port, title, width, height, fullscreen, native.method_queue, native.response_queue
+    args = host, port, title, width, height, fullscreen, frameless, native.method_queue, native.response_queue
     process = mp.Process(target=open_window, args=args, daemon=False)
     process = mp.Process(target=open_window, args=args, daemon=False)
     process.start()
     process.start()