Bladeren bron

Merge branch 'master' of http://oa.sccehui.com:6101/cmc-coding2/ControlNetwork

rmy 5 maanden geleden
bovenliggende
commit
0bfa4061fc

BIN
Back/GC/__pycache__/GC.cpython-312.pyc Bestand weergeven


BIN
Back/GC/__pycache__/GCcompute.cpython-312.pyc Bestand weergeven


BIN
Back/GC/__pycache__/GCshow.cpython-312.pyc Bestand weergeven


BIN
Back/GC/__pycache__/__init__.cpython-312.pyc Bestand weergeven


BIN
Back/GS/__pycache__/GS.cpython-312.pyc Bestand weergeven


BIN
Back/GS/__pycache__/GScompute.cpython-312.pyc Bestand weergeven


BIN
Back/GS/__pycache__/GSshow.cpython-312.pyc Bestand weergeven


BIN
Back/GS/__pycache__/__init__.cpython-312.pyc Bestand weergeven


+ 9
- 1
Back/Program_Run/file_system_watching.py Bestand weergeven

@@ -4,11 +4,13 @@ from PySide6.QtCore import QCoreApplication
4 4
 from watchdog.observers import Observer
5 5
 import os
6 6
 
7
+
7 8
 class ComboBoxUpdater(FileSystemEventHandler):
8 9
     def __init__(self, comboBox, sql_folder):
9 10
         super().__init__()
10 11
         self.comboBox = comboBox
11 12
         self.sql_folder = sql_folder
13
+        self.selected_db = None  # 新增属性来存储当前选中的数据库
12 14
 
13 15
     def on_modified(self, event):
14 16
         if event.is_directory:
@@ -29,6 +31,8 @@ class ComboBoxUpdater(FileSystemEventHandler):
29 31
             self.update_combo_box()
30 32
 
31 33
     def update_combo_box(self):
34
+        # 保存当前选中的数据库
35
+        self.selected_db = self.comboBox.currentText()
32 36
         # 清空现有的 comboBox 内容
33 37
         self.comboBox.clear()
34 38
 
@@ -42,4 +46,8 @@ class ComboBoxUpdater(FileSystemEventHandler):
42 46
 
43 47
         # 如果没有找到任何数据库文件,显示提示信息
44 48
         if not db_files:
45
-            self.comboBox.addItem(QCoreApplication.translate("MainWindow", "未找到数据库文件", None))
49
+            self.comboBox.addItem(QCoreApplication.translate("MainWindow", "未找到数据库文件", None))
50
+
51
+        # 重新设置之前选中的数据库为选中状态
52
+        if self.selected_db in [self.comboBox.itemText(i) for i in range(self.comboBox.count())]:
53
+            self.comboBox.setCurrentText(self.selected_db)

+ 0
- 0
Back/WD/WDcompute.py Bestand weergeven


BIN
Back/WD/__pycache__/WD.cpython-312.pyc Bestand weergeven


BIN
Back/WD/__pycache__/WDcompute.cpython-312.pyc Bestand weergeven


BIN
Back/WD/__pycache__/WDshow.cpython-312.pyc Bestand weergeven


BIN
Back/WD/__pycache__/__init__.cpython-312.pyc Bestand weergeven


BIN
Back/__pycache__/__init__.cpython-312.pyc Bestand weergeven


+ 8
- 1
Front/main.py Bestand weergeven

@@ -21,6 +21,7 @@ import sys
21 21
 import os
22 22
 import platform
23 23
 
24
+import Back.Program_Run.database_operations
24 25
 # IMPORT / GUI AND MODULES AND WIDGETS
25 26
 # ///////////////////////////////////////////////////////////////
26 27
 from modules import *
@@ -66,6 +67,7 @@ class MainWindow(QMainWindow):
66 67
         # ///////////////////////////////////////////////////////////////
67 68
         self.ui = Ui_MainWindow()
68 69
         self.ui.setupUi(self)
70
+        self.ui.createFile.clicked.connect(self.on_create_file_clicked)
69 71
         # self.comboBox_2 = QComboBox(self)
70 72
         # ...此处为省略代码...
71 73
         global widgets
@@ -245,6 +247,11 @@ class MainWindow(QMainWindow):
245 247
             # 触发按钮点击事件
246 248
             btn.click()
247 249
 
250
+
251
+    # 新增槽函数来调用 create_database_and_tables
252
+    def on_create_file_clicked(self):
253
+        Back.Program_Run.database_operations.create_database_and_tables(self.ui)
254
+
248 255
     # RESIZE EVENTS
249 256
     # ///////////////////////////////////////////////////////////////
250 257
     def resizeEvent(self, event):
@@ -270,4 +277,4 @@ if __name__ == "__main__":
270 277
     app.setWindowIcon(QIcon("icon.ico"))
271 278
     window = MainWindow()
272 279
     # window.resize(1440, 960)  # 高宽
273
-    sys.exit(app.exec_())
280
+    sys.exit(app.exec())

+ 17
- 3
Front/modules/ui_functions.py Bestand weergeven

@@ -296,7 +296,14 @@ class UIFunctions(MainWindow):
296 296
     # 上传文件的方法
297 297
     def execute_script_based_on_selection(self, file_path):
298 298
         current_text = self.ui.comboBox_2.currentText()
299
-        db_path = r"D:/Code/ControlNetwork/UI/SQL/DataBase.db"
299
+        # db_path = r"D:/Code/ControlNetwork/UI/SQL/DataBase.db"
300
+        # 获取当前脚本所在的目录
301
+        current_dir = os.path.dirname(os.path.abspath(__file__))
302
+        # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
303
+        sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
304
+        # 将相对路径转换为绝对路径
305
+        sql_folder = os.path.abspath(sql_folder)
306
+        db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
300 307
         file_path = file_path
301 308
         if current_text == "水准测段高差稳定计算":
302 309
             GC.main_function(file_path, db_path)
@@ -311,8 +318,15 @@ class UIFunctions(MainWindow):
311 318
     # 计算与展示文件的方法
312 319
     def compute_show_process_excel_file(self, file_path):
313 320
         current_text = self.ui.comboBox_2.currentText()
314
-        db_path = r"D:/Code/ControlNetwork/UI/SQL/DataBase.db"
315
-        #转换为utf-8
321
+        # db_path = r"D:/Code/ControlNetwork/UI/SQL/DataBase.db"
322
+        # 获取当前脚本所在的目录
323
+        current_dir = os.path.dirname(os.path.abspath(__file__))
324
+        # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
325
+        sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
326
+        # 将相对路径转换为绝对路径
327
+        sql_folder = os.path.abspath(sql_folder)
328
+        db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
329
+        # 转换为utf-8
316 330
         excelname = os.path.basename(file_path)
317 331
         utf_en = excelname.encode('utf-8')
318 332
         if current_text == "水准测段高差稳定计算":

Laden…
Annuleren
Opslaan