直接在Import之后加上这句代码即可
os.environ["WEBVIEW2_USER_DATA_FOLDER"] = os.path.join(os.path.expanduser("~"), "Example_APP")
示例代码:
import os
from nicegui import ui
# user_data_folder = os.path.join(os.path.expanduser("~"), "sdc_rpa", "test", "user_data")
# 修改webview2初次启动时WebView2创建文件夹的目录位置,避免直接在当前运行目录下生成
os.environ["WEBVIEW2_USER_DATA_FOLDER"] = os.path.join(os.path.expanduser("~"), "Example_APP")
class Demo:
def __init__(self):
self.number = 1
demo = Demo()
v = ui.checkbox('visible', value=True)
with ui.column().bind_visibility_from(v, 'value'):
ui.slider(min=1, max=3).bind_value(demo, 'number')
ui.toggle({1: 'A', 2: 'B', 3: 'C'}).bind_value(demo, 'number')
ui.number().bind_value(demo, 'number')
# ui.run(reload=False, native=True)
ui.run(reload=False, native=True)
标签:当前目录,demo,NiceGUI,number,value,文件夹,ui,path,os
From: https://www.cnblogs.com/jwjh/p/18610813