Skip to content

Commit

Permalink
解决Win下active_window为None的问题、焦点的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Nov 24, 2023
1 parent b82f535 commit 7324e87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 4 additions & 5 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import multiprocessing
import os
import pathlib
import platform
import sys
import time
from functools import wraps
Expand Down Expand Up @@ -216,7 +215,7 @@ def log(ws):
def open_file_dialog():
import webview

window = webview.active_window()
window = webview.windows[0]
file_path = window.create_file_dialog(dialog_type=webview.OPEN_DIALOG)
if file_path:
return file_path[0]
Expand All @@ -229,7 +228,7 @@ def open_file_dialog():
def open_folder_dialog():
import webview

window = webview.active_window()
window = webview.windows[0]
folder_path = window.create_file_dialog(dialog_type=webview.FOLDER_DIALOG)
if folder_path:
return folder_path[0]
Expand All @@ -242,7 +241,7 @@ def open_folder_dialog():
def import_from_image():
import webview

window = webview.active_window()
window = webview.windows[0]
file_path = window.create_file_dialog(dialog_type=webview.OPEN_DIALOG)
if not file_path:
return "No file selected."
Expand Down Expand Up @@ -280,7 +279,7 @@ def save_file_dialog():

img = qrcode.export(plan, upper, conf["theme"])

window = webview.active_window()
window = webview.windows[0]
img_path = window.create_file_dialog(
dialog_type=webview.SAVE_DIALOG,
save_filename="plan.png",
Expand Down
7 changes: 6 additions & 1 deletion webview_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def is_port_in_use(port):
width=width,
height=height,
text_select=True,
hidden=True,
)

window.events.resized += on_resized
Expand All @@ -191,7 +192,11 @@ def is_port_in_use(port):
sleep(0.1)

splash.stop()
webview.start()

def show_window(window):
window.show()

webview.start(show_window, window)

window = None

Expand Down

0 comments on commit 7324e87

Please sign in to comment.