|
@@ -36,6 +36,16 @@ from Front.modules import *
|
36
|
36
|
from Front.modules import Settings
|
37
|
37
|
from Front.widgets import *
|
38
|
38
|
|
|
39
|
+def resource_path(relative_path):
|
|
40
|
+ """ Get the absolute path to the resource, works for dev and for cx_Freeze """
|
|
41
|
+ try:
|
|
42
|
+ # cx_Freeze creates a temp folder and stores path in _MEIPASS
|
|
43
|
+ base_path = sys._MEIPASS
|
|
44
|
+ except Exception:
|
|
45
|
+ base_path = os.path.abspath(".")
|
|
46
|
+
|
|
47
|
+ return os.path.join(base_path, relative_path)
|
|
48
|
+
|
39
|
49
|
# IMPORT / GUI AND MODULES AND WIDGETS
|
40
|
50
|
# ///////////////////////////////////////////////////////////////
|
41
|
51
|
# 将项目根目录添加到 sys.path
|
|
@@ -787,8 +797,7 @@ class MainWindow(QMainWindow):
|
787
|
797
|
# 清空 dblist 以确保每次初始化时都是空的
|
788
|
798
|
self.dblist = []
|
789
|
799
|
# 初始化全部数据库
|
790
|
|
- # inpath = r'D:\4work_now\20240819GS\20241211\SQL'
|
791
|
|
- inpath = os.path.abspath('../SQL')
|
|
800
|
+ inpath = resource_path('SQL')
|
792
|
801
|
# 读取所有的数据库名
|
793
|
802
|
sqlitem = []
|
794
|
803
|
id = 1
|
|
@@ -1105,8 +1114,7 @@ class MainWindow(QMainWindow):
|
1105
|
1114
|
# 获取应用的安装目录
|
1106
|
1115
|
app_install_dir = os.getcwd()
|
1107
|
1116
|
# 构建数据库路径
|
1108
|
|
- db_path = os.path.join(app_install_dir, '..', 'SQL', 'DataBase.db')
|
1109
|
|
- db_path = os.path.abspath(db_path)
|
|
1117
|
+ db_path = resource_path(os.path.join('SQL', 'DataBase.db'))
|
1110
|
1118
|
file_name = "平面控制网稳定性计算示例表.xlsx"
|
1111
|
1119
|
excelname_utf8 = file_name.encode('utf-8')
|
1112
|
1120
|
Back.WD.WDExport.main_function_example(self, db_path, excelname_utf8)
|
|
@@ -1115,8 +1123,7 @@ class MainWindow(QMainWindow):
|
1115
|
1123
|
# 获取应用的安装目录
|
1116
|
1124
|
app_install_dir = os.getcwd()
|
1117
|
1125
|
# 构建数据库路径
|
1118
|
|
- db_path = os.path.join(app_install_dir, '..', 'SQL', 'DataBase.db')
|
1119
|
|
- db_path = os.path.abspath(db_path)
|
|
1126
|
+ db_path = resource_path(os.path.join('SQL', 'DataBase.db'))
|
1120
|
1127
|
file_name = "控制网复测平面基准计算示例表.xlsx"
|
1121
|
1128
|
excelname_utf8 = file_name.encode('utf-8')
|
1122
|
1129
|
Back.GS.GSExport.main_function_example(self, db_path, excelname_utf8)
|
|
@@ -1125,8 +1132,7 @@ class MainWindow(QMainWindow):
|
1125
|
1132
|
# 获取应用的安装目录
|
1126
|
1133
|
app_install_dir = os.getcwd()
|
1127
|
1134
|
# 构建数据库路径
|
1128
|
|
- db_path = os.path.join(app_install_dir, '..', 'SQL', 'DataBase.db')
|
1129
|
|
- db_path = os.path.abspath(db_path)
|
|
1135
|
+ db_path = resource_path(os.path.join('SQL', 'DataBase.db'))
|
1130
|
1136
|
file_name = "水准测段高差稳定计算示例文件.xlsx"
|
1131
|
1137
|
utf_en = file_name.encode('utf-8')
|
1132
|
1138
|
# 调用main_function_example函数
|