|
36 | 36 | from nicegui import app, ui |
37 | 37 | from nicegui.events import KeyEventArguments |
38 | 38 | import subprocess |
39 | | - |
40 | 39 | app.native.window_args["resizable"] = True |
41 | 40 | app.native.start_args["debug"] = True |
42 | 41 | # app.native.settings['ALLOW_DOWNLOADS'] = True # export "downloads" ? |
43 | | -app.native.settings["MATPLOTLIB"] = False |
44 | 42 |
|
45 | 43 | editor_fontsize = 18 |
46 | 44 | # TODO: consider separate editor execution thread from nicegui thread |
47 | | - |
| 45 | +import platform |
48 | 46 |
|
49 | 47 | # run ocp_vscode in a subprocess |
50 | 48 | def startup_all(): |
51 | 49 | global ocpcv_proc |
| 50 | + |
| 51 | + if platform.system == "Windows": |
| 52 | + ocpcv_proc = subprocess.Popen([r"uv\uv.exe", "run", "python", "-m", "ocp_vscode"]) |
| 53 | + else: |
| 54 | + ocpcv_proc = subprocess.Popen([r"uv/uv", "run", "python", "-m", "ocp_vscode"]) |
52 | 55 | # spawn separate viewer process |
53 | | - ocpcv_proc = subprocess.Popen(["python", "-m", "ocp_vscode"]) |
54 | 56 | # pre-import build123d and ocp_vscode in main thread |
55 | 57 | exec("from build123d import *\nfrom ocp_vscode import *") |
56 | 58 |
|
@@ -83,7 +85,7 @@ def shutdown_all(): |
83 | 85 | # ui.button('shutdown', on_click=lambda: shutdown_all()) # just close the window |
84 | 86 | code = ( |
85 | 87 | ui.codemirror( |
86 | | - 'print("Edit me!")\nprint("hello world")', |
| 88 | + 'from build123d import *\nfrom ocp_vscode import *\nset_port(3939)\na_box = Box(1,2,3)\nshow(a_box)', |
87 | 89 | language="Python", |
88 | 90 | theme="vscodeLight", |
89 | 91 | ) |
@@ -111,8 +113,8 @@ def handle_key(e: KeyEventArguments): |
111 | 113 | app.on_shutdown(shutdown_all) # register shutdown handler |
112 | 114 | ui.run( |
113 | 115 | native=True, |
114 | | - window_size=(1800, 900), |
115 | | - title="nicegui-cadviewer", |
| 116 | + window_size=(1700, 900), |
| 117 | + title="nice123d", |
116 | 118 | fullscreen=False, |
117 | 119 | reload=False, |
118 | 120 | ) |
|
0 commit comments