更新了gui界面
This commit is contained in:
125
gui.py
125
gui.py
@@ -844,66 +844,65 @@ def index():
|
||||
ui.label("中能建西北院海上能源业务开发部").classes("text-xl font-bold")
|
||||
|
||||
with ui.row().classes("w-full p-4 gap-4"):
|
||||
with ui.card().classes("w-1/4 p-4 shadow-md"):
|
||||
with ui.card().classes("w-3/4 p-4 shadow-md"):
|
||||
ui.label("配置面板").classes("text-xl font-semibold mb-4 border-b pb-2")
|
||||
with ui.row(align_items='center').classes('w-full'):
|
||||
async def export_template():
|
||||
from generate_template import create_template
|
||||
import shutil
|
||||
async def save_template(path):
|
||||
# 生成模板到当前目录
|
||||
create_template()
|
||||
source = "coordinates.xlsx"
|
||||
if os.path.exists(source):
|
||||
shutil.copy2(source, path)
|
||||
else:
|
||||
raise FileNotFoundError("无法生成模板文件")
|
||||
|
||||
async def export_template():
|
||||
from generate_template import create_template
|
||||
import shutil
|
||||
await save_file_with_dialog(
|
||||
"coordinates.xlsx",
|
||||
save_template,
|
||||
"Excel Files (*.xlsx)"
|
||||
)
|
||||
|
||||
async def save_template(path):
|
||||
# 生成模板到当前目录
|
||||
create_template()
|
||||
source = "coordinates.xlsx"
|
||||
if os.path.exists(source):
|
||||
shutil.copy2(source, path)
|
||||
else:
|
||||
raise FileNotFoundError("无法生成模板文件")
|
||||
ui.button("导出 Excel 模板", on_click=export_template).classes(
|
||||
" w-1/4"
|
||||
).props("icon=file_download outline color=primary")
|
||||
|
||||
await save_file_with_dialog(
|
||||
"coordinates.xlsx",
|
||||
save_template,
|
||||
"Excel Files (*.xlsx)"
|
||||
# async def test_save_dialog():
|
||||
# async def dummy_callback(path):
|
||||
# # 仅作为测试,实际不写入文件,只弹出通知
|
||||
# ui.notify(f"测试成功!选定路径: {path}", type="info")
|
||||
|
||||
# await save_file_with_dialog(
|
||||
# "test_save_dialog.txt", dummy_callback, "Text Files (*.txt)"
|
||||
# )
|
||||
|
||||
# ui.button("测试对话框", on_click=test_save_dialog).classes(
|
||||
# "w-full mb-4"
|
||||
# ).props("icon=bug_report outline color=orange")
|
||||
with ui.column().classes('w-1/4'):
|
||||
ui.label("1. 上传坐标文件 (.xlsx)").classes("font-medium")
|
||||
|
||||
# 使用 .no-list CSS 隐藏 Quasar 默认列表,完全自定义文件显示
|
||||
refs["upload_widget"] = ui.upload(
|
||||
label="选择Excel文件", on_upload=handle_upload, auto_upload=True
|
||||
).classes("w-full mb-2 no-list")
|
||||
|
||||
# 自定义文件显示容器
|
||||
refs["current_file_container"] = ui.column().classes("w-full mb-4")
|
||||
with refs["current_file_container"]:
|
||||
ui.label("未选择文件").classes("text-xs text-gray-500 italic ml-1")
|
||||
|
||||
refs["run_btn"] = (
|
||||
ui.button(
|
||||
"运行方案对比",
|
||||
on_click=run_analysis,
|
||||
)
|
||||
.classes("w-1/4 py-4")
|
||||
.props("icon=play_arrow color=secondary")
|
||||
)
|
||||
|
||||
ui.button("导出 Excel 模板", on_click=export_template).classes(
|
||||
"w-full mb-4"
|
||||
).props("icon=file_download outline color=primary")
|
||||
|
||||
async def test_save_dialog():
|
||||
async def dummy_callback(path):
|
||||
# 仅作为测试,实际不写入文件,只弹出通知
|
||||
ui.notify(f"测试成功!选定路径: {path}", type="info")
|
||||
|
||||
await save_file_with_dialog(
|
||||
"test_save_dialog.txt", dummy_callback, "Text Files (*.txt)"
|
||||
)
|
||||
|
||||
ui.button("测试对话框", on_click=test_save_dialog).classes(
|
||||
"w-full mb-4"
|
||||
).props("icon=bug_report outline color=orange")
|
||||
|
||||
ui.label("1. 上传坐标文件 (.xlsx)").classes("font-medium")
|
||||
|
||||
# 使用 .no-list CSS 隐藏 Quasar 默认列表,完全自定义文件显示
|
||||
refs["upload_widget"] = ui.upload(
|
||||
label="选择Excel文件", on_upload=handle_upload, auto_upload=True
|
||||
).classes("w-full mb-2 no-list")
|
||||
|
||||
# 自定义文件显示容器
|
||||
refs["current_file_container"] = ui.column().classes("w-full mb-4")
|
||||
with refs["current_file_container"]:
|
||||
ui.label("未选择文件").classes("text-xs text-gray-500 italic ml-1")
|
||||
|
||||
refs["run_btn"] = (
|
||||
ui.button(
|
||||
"运行方案对比",
|
||||
on_click=run_analysis,
|
||||
)
|
||||
.classes("w-full mt-4 py-4")
|
||||
.props("icon=play_arrow color=secondary")
|
||||
)
|
||||
|
||||
with ui.column().classes("w-3/4 gap-4"):
|
||||
# 新增:信息展示卡片
|
||||
with (
|
||||
@@ -1021,12 +1020,12 @@ if getattr(sys, "frozen", False):
|
||||
)
|
||||
else:
|
||||
# 普通使用环境保留日志功能
|
||||
# ui.run(title="海上风电场集电线路优化", host='127.0.0.1', reload=True, port=target_port, native=False)
|
||||
ui.run(
|
||||
title="海上风电场集电线路优化",
|
||||
host="127.0.0.1",
|
||||
port=target_port,
|
||||
reload=False,
|
||||
window_size=(1280, 800),
|
||||
native=True,
|
||||
)
|
||||
ui.run(title="海上风电场集电线路优化", host='127.0.0.1', reload=True, port=target_port, native=False)
|
||||
# ui.run(
|
||||
# title="海上风电场集电线路优化",
|
||||
# host="127.0.0.1",
|
||||
# port=target_port,
|
||||
# reload=True,
|
||||
# window_size=(1280, 800),
|
||||
# native=True,
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user