|
@@ -1,981 +0,0 @@
|
1
|
|
-# ///////////////////////////////////////////////////////////////
|
2
|
|
-#
|
3
|
|
-# BY: WANDERSON M.PIMENTA
|
4
|
|
-# PROJECT MADE WITH: Qt Designer and PySide6
|
5
|
|
-# V: 1.0.0
|
6
|
|
-#
|
7
|
|
-# This project can be used freely for all uses, as long as they maintain the
|
8
|
|
-# respective credits only in the Python scripts, any information in the visual
|
9
|
|
-# interface (GUI) can be modified without any implication.
|
10
|
|
-#
|
11
|
|
-# There are limitations on Qt licenses if you want to use your products
|
12
|
|
-# commercially, I recommend reading them on the official website:
|
13
|
|
-# https://doc.qt.io/qtforpython/licenses.html
|
14
|
|
-#
|
15
|
|
-# ///////////////////////////////////////////////////////////////
|
16
|
|
-from idlelib.searchengine import search_reverse
|
17
|
|
-
|
18
|
|
-from PySide6.QtWidgets import QFileDialog,QWidget, QVBoxLayout, QTreeWidget, QApplication, QTreeWidgetItem
|
19
|
|
-from PySide6.QtCore import Signal, Qt, Slot, QObject
|
20
|
|
-from PySide6.QtSql import QSqlTableModel,QSqlDatabase
|
21
|
|
-import sqlite3
|
22
|
|
-from PySide6.QtGui import QIcon
|
23
|
|
-
|
24
|
|
-
|
25
|
|
-import sys
|
26
|
|
-import os
|
27
|
|
-import platform
|
28
|
|
-
|
29
|
|
-from tkinter import messagebox
|
30
|
|
-
|
31
|
|
-# IMPORT / GUI AND MODULES AND WIDGETS
|
32
|
|
-# ///////////////////////////////////////////////////////////////
|
33
|
|
-from modules import *
|
34
|
|
-from widgets import *
|
35
|
|
-
|
36
|
|
-os.environ["QT_FONT_DPI"] = "96" # FIX Problem for High DPI and Scale above 100%
|
37
|
|
-
|
38
|
|
-# SET AS GLOBAL WIDGETS
|
39
|
|
-# ///////////////////////////////////////////////////////////////
|
40
|
|
-widgets = None
|
41
|
|
-excelname = ''
|
42
|
|
-
|
43
|
|
-# 获取项目根目录
|
44
|
|
-project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
45
|
|
-# 将项目根目录添加到 sys.path
|
46
|
|
-sys.path.append(project_root)
|
47
|
|
-
|
48
|
|
-
|
49
|
|
-# 表格的模型
|
50
|
|
-class MyTableModel(QAbstractTableModel):
|
51
|
|
- def __init__(self, data):
|
52
|
|
- super().__init__()
|
53
|
|
- self._data = data
|
54
|
|
-
|
55
|
|
- # 重新定义行数
|
56
|
|
- def rowCount(self, parent=QModelIndex()):
|
57
|
|
- return len(self._data)
|
58
|
|
-
|
59
|
|
- # 重新定义列数
|
60
|
|
- def columnCount(self, parent=QModelIndex()):
|
61
|
|
- return len(self._data[0]) if self._data else 0
|
62
|
|
-
|
63
|
|
- # 重新定义数据
|
64
|
|
- def data(self, index, role=Qt.DisplayRole):
|
65
|
|
- if not index.isValid():
|
66
|
|
- return None
|
67
|
|
- if role == Qt.DisplayRole:
|
68
|
|
- return self._data[index.row()][index.column()]
|
69
|
|
- return None
|
70
|
|
-
|
71
|
|
-class TreeWidgetItem:
|
72
|
|
- def __init__(self, id: any, parent_id: any, name: str,icon: QIcon = None, extend: object = None):
|
73
|
|
- """
|
74
|
|
- 菜单数据接口
|
75
|
|
- :param id: ID
|
76
|
|
- :param parent_id: 父ID
|
77
|
|
- :param name: 菜单名称
|
78
|
|
- :param icon: 图标
|
79
|
|
- :param extend: 扩展数据
|
80
|
|
- """
|
81
|
|
- self.id: any = id
|
82
|
|
- self.parent_id: any = parent_id
|
83
|
|
- self.name: str = name
|
84
|
|
- self.extend: object = extend
|
85
|
|
- # 实例化
|
86
|
|
- self.treeWidgetItem = QTreeWidgetItem([self.name])
|
87
|
|
- # 存储相关数据
|
88
|
|
- self.treeWidgetItem.setData(0, Qt.UserRole + 1,extend )
|
89
|
|
- self.treeWidgetItem.setIcon(0, QIcon(':/icons/default.png'))
|
90
|
|
- if icon is not None:
|
91
|
|
- self.treeWidgetItem.setIcon(0, icon)
|
92
|
|
-
|
93
|
|
-class ElTreeData(QObject):
|
94
|
|
- """
|
95
|
|
- Data Model
|
96
|
|
- """
|
97
|
|
- items_changed: Signal = Signal(str)
|
98
|
|
- styleSheet_changed: Signal = Signal(str)
|
99
|
|
-
|
100
|
|
- def __init__(self, items: list[TreeWidgetItem] = None, styleSheet: str = None):
|
101
|
|
- super(ElTreeData, self).__init__()
|
102
|
|
- # 定义数据
|
103
|
|
- self._items: list[TreeWidgetItem]
|
104
|
|
- self._styleSheet: str
|
105
|
|
- # 初始化数据
|
106
|
|
- self.items = items
|
107
|
|
- self.styleSheet = styleSheet
|
108
|
|
-
|
109
|
|
- @property
|
110
|
|
- def items(self):
|
111
|
|
- return self._items
|
112
|
|
-
|
113
|
|
- @items.setter
|
114
|
|
- def items(self, value):
|
115
|
|
- self._items = value
|
116
|
|
- # 数据改变时发出信号
|
117
|
|
- self.items_changed.emit(self.items)
|
118
|
|
-
|
119
|
|
- @property
|
120
|
|
- def styleSheet(self):
|
121
|
|
- return self._styleSheet
|
122
|
|
-
|
123
|
|
- @styleSheet.setter
|
124
|
|
- def styleSheet(self, value):
|
125
|
|
- self._styleSheet = value
|
126
|
|
- # 数据改变时发出信号
|
127
|
|
- self.styleSheet_changed.emit(self.styleSheet)
|
128
|
|
-
|
129
|
|
-#全数据库
|
130
|
|
-class ElTree(QWidget):
|
131
|
|
- """
|
132
|
|
- Control
|
133
|
|
- """
|
134
|
|
- itemClicked: Signal = Signal(object)
|
135
|
|
- itemDoubleClicked: Signal = Signal(object)
|
136
|
|
-
|
137
|
|
- def __init__(self, treeData: ElTreeData, parent=None):
|
138
|
|
- super(ElTree, self).__init__(parent=parent)
|
139
|
|
-
|
140
|
|
- self.data = treeData
|
141
|
|
- # 将按钮的点击信号绑定到当前类的点击信号
|
142
|
|
- widgets.allTreeWidget.itemClicked.connect(lambda item: self.itemClicked.emit(item.data(0, Qt.UserRole + 1)))
|
143
|
|
- widgets.allTreeWidget.itemDoubleClicked.connect(lambda item: self.itemDoubleClicked.emit(item.data(0, Qt.UserRole + 1)))
|
144
|
|
- self.__render_items(True)
|
145
|
|
-
|
146
|
|
- def __render_items(self, is_clear: bool):
|
147
|
|
- if is_clear:
|
148
|
|
- widgets.allTreeWidget.clear()
|
149
|
|
- widgets.qureyTreeWidget.clear()
|
150
|
|
- widgets.allTreeWidget.setColumnCount(1)
|
151
|
|
- widgets.allTreeWidget.setHeaderHidden(True)
|
152
|
|
- widgets.qureyTreeWidget.setColumnCount(1)
|
153
|
|
- widgets.qureyTreeWidget.setHeaderHidden(True)
|
154
|
|
- if self.data.items is not None:
|
155
|
|
- # 转为字典
|
156
|
|
- mapping: dict[any, TreeWidgetItem] = dict(zip([i.id for i in self.data.items], self.data.items))
|
157
|
|
- # 树容器
|
158
|
|
- treeWidgetItems: list[QTreeWidgetItem] = []
|
159
|
|
- for d in self.data.items:
|
160
|
|
- # 如果找不到父级项,则是根节点
|
161
|
|
- parent: TreeWidgetItem = mapping.get(d.parent_id)
|
162
|
|
- if parent is None:
|
163
|
|
- treeWidgetItems.append(d.treeWidgetItem)
|
164
|
|
- else:
|
165
|
|
- parent.treeWidgetItem.addChild(d.treeWidgetItem)
|
166
|
|
-
|
167
|
|
- # 挂载到树上
|
168
|
|
- widgets.allTreeWidget.insertTopLevelItems(0, treeWidgetItems)
|
169
|
|
-
|
170
|
|
-#查询
|
171
|
|
-class ElTree1(QWidget):
|
172
|
|
- """
|
173
|
|
- Control
|
174
|
|
- """
|
175
|
|
- itemClicked: Signal = Signal(object)
|
176
|
|
- itemDoubleClicked: Signal = Signal(object)
|
177
|
|
-
|
178
|
|
- def __init__(self, treeData: ElTreeData, parent=None):
|
179
|
|
- super(ElTree1, self).__init__(parent=parent)
|
180
|
|
- self.data = treeData
|
181
|
|
- # 将按钮的点击信号绑定到当前类的点击信号
|
182
|
|
- widgets.qureyTreeWidget.itemClicked.connect(lambda item: self.itemClicked.emit(item.data(0, Qt.UserRole + 1)))
|
183
|
|
- widgets.qureyTreeWidget.itemDoubleClicked.connect(lambda item: self.itemDoubleClicked.emit(item.data(0, Qt.UserRole + 1)))
|
184
|
|
- self.__render_items(True)
|
185
|
|
-
|
186
|
|
- def __render_items(self, is_clear: bool):
|
187
|
|
- if is_clear:
|
188
|
|
- widgets.qureyTreeWidget.clear()
|
189
|
|
- widgets.qureyTreeWidget.setColumnCount(1)
|
190
|
|
- widgets.qureyTreeWidget.setHeaderHidden(True)
|
191
|
|
- if self.data.items is not None:
|
192
|
|
- # 转为字典
|
193
|
|
- mapping: dict[any, TreeWidgetItem] = dict(zip([i.id for i in self.data.items], self.data.items))
|
194
|
|
- # 树容器
|
195
|
|
- treeWidgetItems: list[QTreeWidgetItem] = []
|
196
|
|
- for d in self.data.items:
|
197
|
|
- # 如果找不到父级项,则是根节点
|
198
|
|
- parent: TreeWidgetItem = mapping.get(d.parent_id)
|
199
|
|
- if parent is None:
|
200
|
|
- treeWidgetItems.append(d.treeWidgetItem)
|
201
|
|
- else:
|
202
|
|
- parent.treeWidgetItem.addChild(d.treeWidgetItem)
|
203
|
|
-
|
204
|
|
- # 挂载到树上
|
205
|
|
- widgets.qureyTreeWidget.insertTopLevelItems(0, treeWidgetItems)
|
206
|
|
-
|
207
|
|
-class MainWindow(QMainWindow):
|
208
|
|
- def __init__(self):
|
209
|
|
- QMainWindow.__init__(self)
|
210
|
|
- # super().__init__()
|
211
|
|
- # SET AS GLOBAL WIDGETS
|
212
|
|
- # ///////////////////////////////////////////////////////////////
|
213
|
|
- self.ui = Ui_MainWindow()
|
214
|
|
- self.ui.setupUi(self)
|
215
|
|
- # self.comboBox_2 = QComboBox(self)
|
216
|
|
- # ...此处为省略代码...
|
217
|
|
- global widgets
|
218
|
|
- widgets = self.ui
|
219
|
|
-
|
220
|
|
- # 是否使用系统自带标题栏 True是不使用,False使用
|
221
|
|
- # ///////////////////////////////////////////////////////////////
|
222
|
|
- Settings.ENABLE_CUSTOM_TITLE_BAR = True
|
223
|
|
-
|
224
|
|
- # APP名称
|
225
|
|
- # ///////////////////////////////////////////////////////////////
|
226
|
|
- title = "控制网复测平面基准归算程序"
|
227
|
|
- description = "控制网复测平面基准归算程序"
|
228
|
|
- # APPLY TEXTS
|
229
|
|
- self.setWindowTitle(title)
|
230
|
|
- widgets.titleRightInfo.setText(description)
|
231
|
|
-
|
232
|
|
- # TOGGLE MENU
|
233
|
|
- # ///////////////////////////////////////////////////////////////
|
234
|
|
- widgets.toggleButton.clicked.connect(lambda: UIFunctions.toggleMenu(self, True))
|
235
|
|
-
|
236
|
|
- # SET UI DEFINITIONS
|
237
|
|
- # ///////////////////////////////////////////////////////////////
|
238
|
|
- UIFunctions.uiDefinitions(self)
|
239
|
|
-
|
240
|
|
- # QTableWidget PARAMETERS
|
241
|
|
- # ///////////////////////////////////////////////////////////////
|
242
|
|
- # widgets.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
243
|
|
-
|
244
|
|
- # 点击事件
|
245
|
|
- # ///////////////////////////////////////////////////////////////
|
246
|
|
-
|
247
|
|
- # 左边菜单
|
248
|
|
- # 首页
|
249
|
|
- widgets.btn_home.clicked.connect(self.buttonClick)
|
250
|
|
- # 输入表格
|
251
|
|
- widgets.btn_widgets.clicked.connect(self.buttonClick)
|
252
|
|
- # 成果预览
|
253
|
|
- widgets.btn_new.clicked.connect(self.buttonClick)
|
254
|
|
- # 数据一览
|
255
|
|
- widgets.btn_data.clicked.connect(self.buttonClick)
|
256
|
|
- # 皮肤切换
|
257
|
|
- widgets.btn_message.clicked.connect(self.buttonClick)
|
258
|
|
- # 打开上传文件夹
|
259
|
|
- widgets.upload.clicked.connect(self.buttonClick)
|
260
|
|
-
|
261
|
|
-
|
262
|
|
- # 拓展左侧栏
|
263
|
|
- # def openCloseLeftBox():
|
264
|
|
- # UIFunctions.toggleLeftBox(self, True)
|
265
|
|
- # widgets.toggleLeftBox.clicked.connect(openCloseLeftBox)
|
266
|
|
- # widgets.extraCloseColumnBtn.clicked.connect(openCloseLeftBox)
|
267
|
|
-
|
268
|
|
- # EXTRA RIGHT BOX
|
269
|
|
- def openCloseRightBox():
|
270
|
|
- UIFunctions.toggleRightBox(self, True)
|
271
|
|
-
|
272
|
|
- widgets.settingsTopBtn.clicked.connect(openCloseRightBox)
|
273
|
|
-
|
274
|
|
-
|
275
|
|
-
|
276
|
|
-
|
277
|
|
- # 展示APP
|
278
|
|
- # ///////////////////////////////////////////////////////////////
|
279
|
|
- self.show()
|
280
|
|
-
|
281
|
|
- # 设置主题
|
282
|
|
- # ///////////////////////////////////////////////////////////////
|
283
|
|
- if getattr(sys, 'frozen', False):
|
284
|
|
- absPath = os.path.dirname(os.path.abspath(sys.executable))
|
285
|
|
- elif __file__:
|
286
|
|
- absPath = os.path.dirname(os.path.abspath(__file__))
|
287
|
|
- useCustomTheme = True
|
288
|
|
- self.useCustomTheme = useCustomTheme
|
289
|
|
- self.absPath = absPath
|
290
|
|
- # themeFile = r"Front\themes\py_dracula_light.qss"
|
291
|
|
- themeFile = os.path.abspath(os.path.join(self.absPath, "themes/py_dracula_light.qss"))
|
292
|
|
-
|
293
|
|
- # 设置主题和HACKS
|
294
|
|
- if useCustomTheme:
|
295
|
|
- # LOAD AND APPLY STYLE
|
296
|
|
- UIFunctions.theme(self, themeFile, True)
|
297
|
|
-
|
298
|
|
- # SET HACKS
|
299
|
|
- AppFunctions.setThemeHack(self)
|
300
|
|
-
|
301
|
|
- # 设置主页和选择菜单
|
302
|
|
- # ///////////////////////////////////////////////////////////////
|
303
|
|
- widgets.stackedWidget.setCurrentWidget(widgets.home)
|
304
|
|
- widgets.btn_home.setStyleSheet(UIFunctions.selectMenu(widgets.btn_home.styleSheet()))
|
305
|
|
-
|
306
|
|
- #初始化树状数据库
|
307
|
|
- tree_button = self.sql_init()
|
308
|
|
- tree_button.itemClicked.connect(self.computeClick)
|
309
|
|
- tree_button.itemDoubleClicked.connect(self.computeClick)
|
310
|
|
-
|
311
|
|
- self.bind()
|
312
|
|
-
|
313
|
|
- #绑定组件
|
314
|
|
- def bind(self):
|
315
|
|
- # 计算
|
316
|
|
- # widgets.compute.clicked.connect(self.computeClick)
|
317
|
|
- widgets.search.clicked.connect(self.searchClick)
|
318
|
|
-
|
319
|
|
- #删除tableview
|
320
|
|
- def delete_table_view(table_view):
|
321
|
|
- table_view.setParent(None)
|
322
|
|
- table_view.deleteLater()
|
323
|
|
-
|
324
|
|
- #默认第一个参数是self,所以使用时只有一个参数
|
325
|
|
- #稳定性成果表
|
326
|
|
- def Arrange_Data(self,list1):
|
327
|
|
- #最终return的
|
328
|
|
- list2 = []
|
329
|
|
- #点号部分
|
330
|
|
- nlist = []
|
331
|
|
- for data1 in list1:
|
332
|
|
- #点名
|
333
|
|
- #存每一行的数据
|
334
|
|
- resultlist = []
|
335
|
|
- pn = data1[0].decode('utf-8')
|
336
|
|
- resultlist.append(pn)
|
337
|
|
- nlist.append(pn)
|
338
|
|
- resultlist.append(data1[1])
|
339
|
|
- resultlist.append(data1[2])
|
340
|
|
- resultlist.append(data1[3])
|
341
|
|
- resultlist.append(data1[4])
|
342
|
|
- resultlist.append(data1[5])
|
343
|
|
- resultlist.append(data1[6])
|
344
|
|
- resultlist.append(data1[7])
|
345
|
|
- resultlist.append(data1[8])
|
346
|
|
- resultlist.append(data1[9])
|
347
|
|
- resultlist.append(data1[10])
|
348
|
|
- resultlist.append(data1[11])
|
349
|
|
- #判定1
|
350
|
|
- an1 = data1[12].decode('utf-8')
|
351
|
|
- resultlist.append(an1)
|
352
|
|
- resultlist.append(data1[13])
|
353
|
|
- resultlist.append(data1[14])
|
354
|
|
- resultlist.append(data1[15])
|
355
|
|
- #判定2
|
356
|
|
- an2 = data1[16].decode('utf-8')
|
357
|
|
- resultlist.append(an2)
|
358
|
|
- list2.append(resultlist)
|
359
|
|
-
|
360
|
|
- return nlist,list2
|
361
|
|
-
|
362
|
|
- #复测成果表
|
363
|
|
- def Arrange_Data1(self,list1):
|
364
|
|
- #最终return的
|
365
|
|
- list2 = []
|
366
|
|
- #点号部分
|
367
|
|
- nlist = []
|
368
|
|
- for data1 in list1:
|
369
|
|
- #点名
|
370
|
|
- #存每一行的数据
|
371
|
|
- resultlist = []
|
372
|
|
- pn = data1[0].decode('utf-8')
|
373
|
|
- resultlist.append(pn)
|
374
|
|
- nlist.append(pn)
|
375
|
|
- resultlist.append(data1[1])
|
376
|
|
- resultlist.append(data1[2])
|
377
|
|
- resultlist.append(data1[3])
|
378
|
|
- resultlist.append(data1[4])
|
379
|
|
- resultlist.append(data1[5])
|
380
|
|
- resultlist.append(data1[6])
|
381
|
|
- resultlist.append(data1[7])
|
382
|
|
- #判定
|
383
|
|
- an1 = data1[8].decode('utf-8')
|
384
|
|
- resultlist.append(an1)
|
385
|
|
- list2.append(resultlist)
|
386
|
|
-
|
387
|
|
- return nlist,list2
|
388
|
|
-
|
389
|
|
- #基准归算表
|
390
|
|
- def Arrange_Data2(self,list1):
|
391
|
|
- #最终return的
|
392
|
|
- list2 = []
|
393
|
|
- #点号部分
|
394
|
|
- nlist = []
|
395
|
|
- for data1 in list1:
|
396
|
|
- #点名
|
397
|
|
- #存每一行的数据
|
398
|
|
- resultlist = []
|
399
|
|
- pn = data1[0].decode('utf-8')
|
400
|
|
- resultlist.append(pn)
|
401
|
|
- nlist.append(pn)
|
402
|
|
- resultlist.append(data1[1])
|
403
|
|
- resultlist.append(data1[2])
|
404
|
|
- resultlist.append(data1[3])
|
405
|
|
- resultlist.append(data1[4])
|
406
|
|
- resultlist.append(data1[5])
|
407
|
|
- #判定
|
408
|
|
- an1 = data1[6].decode('utf-8')
|
409
|
|
- resultlist.append(an1)
|
410
|
|
- list2.append(resultlist)
|
411
|
|
-
|
412
|
|
- return nlist,list2
|
413
|
|
-
|
414
|
|
- #稳定性成果表
|
415
|
|
- def Data_in_Cell(self,list1):
|
416
|
|
- model = QStandardItemModel()
|
417
|
|
- xx = 0
|
418
|
|
- while xx < len(list1):
|
419
|
|
- data1 = list1[xx]
|
420
|
|
- #点号
|
421
|
|
- cell1 = str(data1[0])
|
422
|
|
- item = QStandardItem(cell1)
|
423
|
|
- model.setItem(xx, 0, item)
|
424
|
|
- #首期
|
425
|
|
- cell1 = str(round(data1[1],4))
|
426
|
|
- item = QStandardItem(cell1)
|
427
|
|
- model.setItem(xx, 1, item)
|
428
|
|
- cell1 = str(round(data1[2],4))
|
429
|
|
- item = QStandardItem(cell1)
|
430
|
|
- model.setItem(xx, 2, item)
|
431
|
|
- #上期
|
432
|
|
- cell1 = str(round(data1[3],4))
|
433
|
|
- item = QStandardItem(cell1)
|
434
|
|
- model.setItem(xx, 3, item)
|
435
|
|
- cell1 = str(round(data1[4],4))
|
436
|
|
- item = QStandardItem(cell1)
|
437
|
|
- model.setItem(xx, 4, item)
|
438
|
|
- #权
|
439
|
|
- cell1 = str(int(data1[5]))
|
440
|
|
- item = QStandardItem(cell1)
|
441
|
|
- model.setItem(xx, 5, item)
|
442
|
|
- #本期
|
443
|
|
- cell1 = str(round(data1[6],4))
|
444
|
|
- item = QStandardItem(cell1)
|
445
|
|
- model.setItem(xx, 6, item)
|
446
|
|
- cell1 = str(round(data1[7],4))
|
447
|
|
- item = QStandardItem(cell1)
|
448
|
|
- model.setItem(xx, 7, item)
|
449
|
|
- #权
|
450
|
|
- cell1 = str(int(data1[8]))
|
451
|
|
- item = QStandardItem(cell1)
|
452
|
|
- model.setItem(xx, 8, item)
|
453
|
|
- #本-首
|
454
|
|
- cell1 = str(round(data1[9],1))
|
455
|
|
- item = QStandardItem(cell1)
|
456
|
|
- model.setItem(xx, 9, item)
|
457
|
|
- cell1 = str(round(data1[10],1))
|
458
|
|
- item = QStandardItem(cell1)
|
459
|
|
- model.setItem(xx, 10, item)
|
460
|
|
- cell1 = str(round(data1[11],1))
|
461
|
|
- item = QStandardItem(cell1)
|
462
|
|
- model.setItem(xx, 11, item)
|
463
|
|
- #判定(如果是稳定则不显示)
|
464
|
|
- cell1 = str(data1[12])
|
465
|
|
- if cell1 == '稳定':
|
466
|
|
- cell1 = ''
|
467
|
|
- item = QStandardItem(cell1)
|
468
|
|
- model.setItem(xx, 12, item)
|
469
|
|
- #本-上
|
470
|
|
- cell1 = str(round(data1[13],1))
|
471
|
|
- item = QStandardItem(cell1)
|
472
|
|
- model.setItem(xx, 13, item)
|
473
|
|
- cell1 = str(round(data1[14],1))
|
474
|
|
- item = QStandardItem(cell1)
|
475
|
|
- model.setItem(xx, 14, item)
|
476
|
|
- cell1 = str(round(data1[15],1))
|
477
|
|
- item = QStandardItem(cell1)
|
478
|
|
- model.setItem(xx, 15, item)
|
479
|
|
- #判定
|
480
|
|
- cell1 = str(data1[16])
|
481
|
|
- if cell1 == '稳定':
|
482
|
|
- cell1 = ''
|
483
|
|
- item = QStandardItem(cell1)
|
484
|
|
- model.setItem(xx, 16, item)
|
485
|
|
- xx = xx + 1
|
486
|
|
- return model
|
487
|
|
-
|
488
|
|
- #复测成果表
|
489
|
|
- def Data_in_Cell1(self,list1):
|
490
|
|
- model = QStandardItemModel()
|
491
|
|
- xx = 0
|
492
|
|
- while xx < len(list1):
|
493
|
|
- data1 = list1[xx]
|
494
|
|
- #点号
|
495
|
|
- cell1 = str(data1[0])
|
496
|
|
- item = QStandardItem(cell1)
|
497
|
|
- model.setItem(xx, 0, item)
|
498
|
|
- #上期
|
499
|
|
- cell1 = str(round(data1[1],4))
|
500
|
|
- item = QStandardItem(cell1)
|
501
|
|
- model.setItem(xx, 1, item)
|
502
|
|
- cell1 = str(round(data1[2],4))
|
503
|
|
- item = QStandardItem(cell1)
|
504
|
|
- model.setItem(xx, 2, item)
|
505
|
|
- #本期
|
506
|
|
- cell1 = str(round(data1[3],4))
|
507
|
|
- item = QStandardItem(cell1)
|
508
|
|
- model.setItem(xx, 3, item)
|
509
|
|
- cell1 = str(round(data1[4],4))
|
510
|
|
- item = QStandardItem(cell1)
|
511
|
|
- model.setItem(xx, 4, item)
|
512
|
|
- #上-本
|
513
|
|
- cell1 = str(round(data1[5],1))
|
514
|
|
- item = QStandardItem(cell1)
|
515
|
|
- model.setItem(xx, 5, item)
|
516
|
|
- cell1 = str(round(data1[6],1))
|
517
|
|
- item = QStandardItem(cell1)
|
518
|
|
- model.setItem(xx, 6, item)
|
519
|
|
- cell1 = str(round(data1[7],1))
|
520
|
|
- item = QStandardItem(cell1)
|
521
|
|
- model.setItem(xx, 7, item)
|
522
|
|
- #判定(如果是稳定则不显示)
|
523
|
|
- cell1 = str(data1[8])
|
524
|
|
- if cell1 == '稳定':
|
525
|
|
- cell1 = ''
|
526
|
|
- item = QStandardItem(cell1)
|
527
|
|
- model.setItem(xx, 8, item)
|
528
|
|
- xx = xx + 1
|
529
|
|
- return model
|
530
|
|
-
|
531
|
|
- #基准归算表
|
532
|
|
- def Data_in_Cell2(self,list1):
|
533
|
|
- model = QStandardItemModel()
|
534
|
|
- xx = 0
|
535
|
|
- while xx < len(list1):
|
536
|
|
- data1 = list1[xx]
|
537
|
|
- #点号
|
538
|
|
- cell1 = str(data1[0])
|
539
|
|
- item = QStandardItem(cell1)
|
540
|
|
- model.setItem(xx, 0, item)
|
541
|
|
- #计算
|
542
|
|
- cell1 = str(round(data1[1],4))
|
543
|
|
- item = QStandardItem(cell1)
|
544
|
|
- model.setItem(xx, 1, item)
|
545
|
|
- cell1 = str(round(data1[2],4))
|
546
|
|
- item = QStandardItem(cell1)
|
547
|
|
- model.setItem(xx, 2, item)
|
548
|
|
- #上-计
|
549
|
|
- cell1 = str(round(data1[3],1))
|
550
|
|
- item = QStandardItem(cell1)
|
551
|
|
- model.setItem(xx, 3, item)
|
552
|
|
- cell1 = str(round(data1[4],1))
|
553
|
|
- item = QStandardItem(cell1)
|
554
|
|
- model.setItem(xx, 4, item)
|
555
|
|
- cell1 = str(round(data1[5],1))
|
556
|
|
- item = QStandardItem(cell1)
|
557
|
|
- model.setItem(xx, 5, item)
|
558
|
|
- #判定(如果是稳定则不显示)
|
559
|
|
- cell1 = str(data1[6])
|
560
|
|
- if cell1 == '稳定':
|
561
|
|
- cell1 = ''
|
562
|
|
- item = QStandardItem(cell1)
|
563
|
|
- model.setItem(xx, 6, item)
|
564
|
|
- xx = xx + 1
|
565
|
|
- return model
|
566
|
|
-
|
567
|
|
- #设一个全局变量,存数据库中所有的包含内容(数据库-三种方法-表)
|
568
|
|
- dblist = []
|
569
|
|
- #初始化数据一览(数据库全展示)
|
570
|
|
- def sql_init(self):
|
571
|
|
- #初始化全部数据库
|
572
|
|
- # inpath = r'D:\4work_now\20240819GS\20241211\SQL'
|
573
|
|
- inpath = os.path.abspath('../SQL')
|
574
|
|
- #读取所有的数据库名
|
575
|
|
- sqlitem = []
|
576
|
|
- id = 1
|
577
|
|
- for filename in os.listdir(inpath):
|
578
|
|
- #数据库
|
579
|
|
- dbname = filename.split('.',-1)[0]
|
580
|
|
- dbpath = os.path.join(inpath,filename)
|
581
|
|
- sqlitem.append(TreeWidgetItem(id,0,dbname,icon=QIcon(os.path.abspath(os.path.join(self.absPath, "images/icons/cil-clone.png")))))
|
582
|
|
- pid = id
|
583
|
|
- id = id + 1
|
584
|
|
- #三种方法
|
585
|
|
- sqlitem.append(TreeWidgetItem(id, pid, '水准测段高差稳定计算', icon=QIcon(os.path.join(self.absPath, "images/icons/cil-description.png"))))
|
586
|
|
- gcid = id
|
587
|
|
- id = id + 1
|
588
|
|
- sqlitem.append(TreeWidgetItem(id, pid, '控制网复测平面基准计算', icon=QIcon(os.path.join(self.absPath, "images/icons/cil-description.png"))))
|
589
|
|
- gsid = id
|
590
|
|
- id = id + 1
|
591
|
|
- sqlitem.append(TreeWidgetItem(id, pid, '平面控制网稳定性计算', icon=QIcon(os.path.join(self.absPath, "images/icons/cil-description.png"))))
|
592
|
|
- wdid = id
|
593
|
|
- id = id + 1
|
594
|
|
- #读取所有的表名(三种方式往下)
|
595
|
|
- db1 = sqlite3.connect(dbpath)
|
596
|
|
- #获取游标
|
597
|
|
- cursor1 = db1.cursor()
|
598
|
|
- sqlstr1 = 'SELECT TableName FROM GC_Input_Param;'
|
599
|
|
- cursor1.execute(sqlstr1)
|
600
|
|
- result1 = cursor1.fetchall()
|
601
|
|
- for re1 in result1:
|
602
|
|
- str1 = re1[0].decode('utf-8')
|
603
|
|
- list1 = []
|
604
|
|
- list1.append(dbname)
|
605
|
|
- list1.append('水准测段高差稳定计算')
|
606
|
|
- list1.append(str1)
|
607
|
|
- self.dblist.append(list1)
|
608
|
|
- sqlitem.append(TreeWidgetItem(id, gcid, str1, icon=QIcon(
|
609
|
|
- os.path.join(self.absPath, "images/icons/cil-file.png")),extend={'listData': list1}))
|
610
|
|
- id = id + 1
|
611
|
|
- sqlstr2 = 'SELECT TableName FROM GS_Input_Param;'
|
612
|
|
- cursor1.execute(sqlstr2)
|
613
|
|
- result2 = cursor1.fetchall()
|
614
|
|
- for re2 in result2:
|
615
|
|
- str2 = re2[0].decode('utf-8')
|
616
|
|
- list2 = []
|
617
|
|
- list2.append(dbname)
|
618
|
|
- list2.append('控制网复测平面基准计算')
|
619
|
|
- list2.append(str2)
|
620
|
|
- self.dblist.append(list2)
|
621
|
|
- sqlitem.append(TreeWidgetItem(id, gsid, str2, icon=QIcon(os.path.join(self.absPath, "images/icons/cil-file.png")),extend={'listData': list2}))
|
622
|
|
- id = id + 1
|
623
|
|
- sqlstr3 = 'SELECT TableName FROM WD_Input_Param;'
|
624
|
|
- cursor1.execute(sqlstr3)
|
625
|
|
- result3 = cursor1.fetchall()
|
626
|
|
- for re3 in result3:
|
627
|
|
- str3 = re3[0].decode('utf-8')
|
628
|
|
- list3 = []
|
629
|
|
- list3.append(dbname)
|
630
|
|
- list3.append('平面控制网稳定性计算')
|
631
|
|
- list3.append(str3)
|
632
|
|
- self.dblist.append(list3)
|
633
|
|
- sqlitem.append(TreeWidgetItem(id, wdid, str3, icon=QIcon(os.path.join(self.absPath, "images/icons/cil-file.png")),extend={'listData': list3}))
|
634
|
|
- id = id + 1
|
635
|
|
- button = ElTree(ElTreeData(sqlitem))
|
636
|
|
- return button
|
637
|
|
-
|
638
|
|
- #关键词查询
|
639
|
|
- def searchClick(self):
|
640
|
|
- # GET BUTTON CLICKED
|
641
|
|
- btn = self.sender()
|
642
|
|
- btnName = btn.objectName()
|
643
|
|
- #获取文本
|
644
|
|
- text1 = self.ui.lineEdit_2.text()
|
645
|
|
- #符合的list
|
646
|
|
- fhlist = []
|
647
|
|
- #查询(待优化)
|
648
|
|
- for list1 in self.dblist:
|
649
|
|
- for li in list1:
|
650
|
|
- if text1 in li:
|
651
|
|
- fhlist.append(list1)
|
652
|
|
- break
|
653
|
|
- #更新item值
|
654
|
|
- sqlitem = []
|
655
|
|
- #前两层是否一致
|
656
|
|
- str1 = ''
|
657
|
|
- str2 = ''
|
658
|
|
- id = 1
|
659
|
|
- pid = 0
|
660
|
|
- fid = 0
|
661
|
|
- zdy = []
|
662
|
|
- for list2 in fhlist:
|
663
|
|
- dbname = list2[0]
|
664
|
|
- if dbname != str1:
|
665
|
|
- str1 = dbname
|
666
|
|
- pid = id
|
667
|
|
- str2 = ''
|
668
|
|
- sqlitem.append(TreeWidgetItem(id, 0, dbname, icon=QIcon(
|
669
|
|
- os.path.join(self.absPath, "images/icons/cil-clone.png"))))
|
670
|
|
- zdy1 = []
|
671
|
|
- zdy1.append(id)
|
672
|
|
- zdy1.append(0)
|
673
|
|
- zdy1.append(dbname)
|
674
|
|
- zdy.append(zdy1)
|
675
|
|
- id = id + 1
|
676
|
|
- mename = list2[1]
|
677
|
|
- if mename != str2:
|
678
|
|
- str2 = mename
|
679
|
|
- fid = id
|
680
|
|
- sqlitem.append(TreeWidgetItem(id, pid, mename, icon=QIcon(
|
681
|
|
- os.path.join(self.absPath, "images/icons/cil-description.png"))))
|
682
|
|
- zdy1 = []
|
683
|
|
- zdy1.append(id)
|
684
|
|
- zdy1.append(pid)
|
685
|
|
- zdy1.append(mename)
|
686
|
|
- zdy.append(zdy1)
|
687
|
|
- id = id + 1
|
688
|
|
- sqlitem.append(TreeWidgetItem(id, fid, list2[2], icon=QIcon(
|
689
|
|
- os.path.join(self.absPath, "images/icons/cil-file.png")), extend={'listData': list2}))
|
690
|
|
- zdy1 = []
|
691
|
|
- zdy1.append(id)
|
692
|
|
- zdy1.append(fid)
|
693
|
|
- zdy1.append(list2[2])
|
694
|
|
- zdy.append(zdy1)
|
695
|
|
- id = id + 1
|
696
|
|
- search_button = ElTree1(ElTreeData(sqlitem))
|
697
|
|
- search_button.itemClicked.connect(self.computeClick)
|
698
|
|
- search_button.itemDoubleClicked.connect(self.computeClick)
|
699
|
|
-
|
700
|
|
- #直接这个基础上改点选输出表格(未改)
|
701
|
|
- def computeClick(self):
|
702
|
|
- # GET BUTTON CLICKED
|
703
|
|
- btn = self.sender()
|
704
|
|
- btnName = btn.objectName()
|
705
|
|
- #判定是否获取的是根节点
|
706
|
|
- pd = 1
|
707
|
|
- select_item = self.ui.qureyTreeWidget.currentItem()
|
708
|
|
- #获取点击的item的text和它对应的上两个节点
|
709
|
|
- str1 = select_item.text(0)
|
710
|
|
- try:
|
711
|
|
- pa_item = select_item.parent()
|
712
|
|
- current_text = pa_item.text(0)
|
713
|
|
- z_item = pa_item.parent()
|
714
|
|
- str3 = z_item.text(0)
|
715
|
|
- except:
|
716
|
|
- pd = -1
|
717
|
|
- if current_text == '':
|
718
|
|
- pd = -1
|
719
|
|
- if str3 == '':
|
720
|
|
- pd = -1
|
721
|
|
- if pd == -1:
|
722
|
|
- pass
|
723
|
|
- else:
|
724
|
|
- #数据库目录
|
725
|
|
- inpath= os.path.abspath('../SQL')
|
726
|
|
- file_path= inpath + '/'+str3
|
727
|
|
- # UIFunctions.compute_show_process_excel_file(self, file_path)
|
728
|
|
- # #转换下
|
729
|
|
- # excelname = os.path.basename(file_path)
|
730
|
|
- # utf_en = excelname.encode('utf-8')
|
731
|
|
- # # file_path = file_path
|
732
|
|
- # if current_text == "水准测段高差稳定计算":
|
733
|
|
- # #只显示一个tab
|
734
|
|
- # self.ui.tabWidget.setTabVisible(0,True)
|
735
|
|
- # self.ui.tabWidget.setTabVisible(1,False)
|
736
|
|
- # self.ui.tabWidget.setTabVisible(2,False)
|
737
|
|
- # #重新设置文字名称
|
738
|
|
- # self.ui.tabWidget.setTabText(0,'测段高差计算表')
|
739
|
|
- #
|
740
|
|
- # # 计算结束自动跳转结果页面,并保留查询内容,以便输出
|
741
|
|
- # widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
|
742
|
|
- # UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
|
743
|
|
- # btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
|
744
|
|
- # elif current_text == "控制网复测平面基准计算":
|
745
|
|
- # #就用已有的选项卡
|
746
|
|
- # self.ui.tabWidget.setTabVisible(0,True)
|
747
|
|
- # self.ui.tabWidget.setTabVisible(1,True)
|
748
|
|
- # self.ui.tabWidget.setTabVisible(2,True)
|
749
|
|
- # #重新设置文字名称
|
750
|
|
- # self.ui.tabWidget.setTabText(0,'复测成果表')
|
751
|
|
- # self.ui.tabWidget.setTabText(1,'基准归算模型')
|
752
|
|
- # self.ui.tabWidget.setTabText(2,'复测基准归算表')
|
753
|
|
- #
|
754
|
|
- # #链接数据库并显示
|
755
|
|
- # # 连接到数据库
|
756
|
|
- # #将结果输出到数据库
|
757
|
|
- # db1 = sqlite3.connect(db_path)
|
758
|
|
- # #获取游标
|
759
|
|
- # cursor1 = db1.cursor()
|
760
|
|
- # #查询表内符合的所有数据(分成两个结果分别显示)
|
761
|
|
- # #复测成果表
|
762
|
|
- # sqlstr1 = 'select PointName,Last_X,Last_Y,Result_X,Result_Y,Last_ResultX,Last_ResultY,Last_ResultP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
|
763
|
|
- # cursor1.execute(sqlstr1,(utf_en,))
|
764
|
|
- # #获取结果集
|
765
|
|
- # result1 = cursor1.fetchall()
|
766
|
|
- # #基准归算表
|
767
|
|
- # sqlstr11 = 'select PointName,Cal_X,Cal_Y,Last_CalX,Last_CalY,Last_CalP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
|
768
|
|
- # cursor1.execute(sqlstr11,(utf_en,))
|
769
|
|
- # #获取结果集
|
770
|
|
- # result2 = cursor1.fetchall()
|
771
|
|
- # #对结果集进行处理,把汉字转换过来,添加表头部分
|
772
|
|
- # nlist1,plist1 = self.Arrange_Data1(result1)
|
773
|
|
- # nlist2,plist2 = self.Arrange_Data2(result2)
|
774
|
|
- # # 创建一个数据模型(复测成果表)
|
775
|
|
- # self.model1 = QStandardItemModel()
|
776
|
|
- # #把数据放进去
|
777
|
|
- # model1 = self.Data_in_Cell1(plist1)
|
778
|
|
- # model2 = self.Data_in_Cell2(plist2)
|
779
|
|
- # #设置表头
|
780
|
|
- # model1.setHorizontalHeaderLabels(['点名', '前期X','前期Y','本期X', '本期Y','前期-本期X','前期-本期Y','前期-本期P','位移判定'])
|
781
|
|
- # model1.setVerticalHeaderLabels(nlist1)
|
782
|
|
- # #QTableView并将数据模型与之关联
|
783
|
|
- # self.ui.resultTableView.setModel(model1)
|
784
|
|
- # self.ui.resultTableView.show()
|
785
|
|
- # #设置表头
|
786
|
|
- # model2.setHorizontalHeaderLabels(['点名', '基准归算X','基准归算Y','前期-归算X','前期-归算Y','前期-归算P','位移判定'])
|
787
|
|
- # model2.setVerticalHeaderLabels(nlist2)
|
788
|
|
- # #QTableView并将数据模型与之关联
|
789
|
|
- # self.ui.reconTableView.setModel(model2)
|
790
|
|
- # self.ui.reconTableView.show()
|
791
|
|
- #
|
792
|
|
- # #富文本的html
|
793
|
|
- # sqlstr2 = 'select Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3 from GS_Trans_Param WHERE TableName = ?'
|
794
|
|
- # cursor1.execute(sqlstr2,(utf_en,))
|
795
|
|
- # #获取结果集
|
796
|
|
- # result1 = cursor1.fetchall()
|
797
|
|
- # str1 = result1[0][0].decode('utf-8')
|
798
|
|
- # str2 = result1[0][1].decode('utf-8')
|
799
|
|
- # n1 = result1[0][2]
|
800
|
|
- # n2 = result1[0][3]
|
801
|
|
- # n3 = result1[0][4]
|
802
|
|
- # n4 = result1[0][5]
|
803
|
|
- # n5 = result1[0][6]
|
804
|
|
- # n6 = result1[0][7]
|
805
|
|
- # str0 = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
806
|
|
- # <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
807
|
|
- # p, li { white-space: pre-wrap; }
|
808
|
|
- # hr { height: 1px; border-width: 0; }
|
809
|
|
- # li.unchecked::marker { content: "\2610"; }
|
810
|
|
- # li.checked::marker { content: "\2612"; }
|
811
|
|
- # </style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
812
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; color:#000000;">"""+str2+"""--"""+str1+"""</span><span style=" font-size:14pt;">已知系统转换公式:</span></p>
|
813
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">X</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n1)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n2)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n3)+"""</span><span style=" font-size:14pt;">)</span></p>
|
814
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">Y</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n4)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n5)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n6)+"""</span><span style=" font-size:14pt;">)</span></p>
|
815
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">式中:</span><span style=" font-size:14pt; font-weight:700; color:#000000;">x、y</span><span style=" font-size:14pt;">为</span><span style=" font-size:14pt; color:#000000;">"""+str2+"""</span><span style=" font-size:14pt;">坐标;</span></p>
|
816
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;"> </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为"""+str1+"""已知系统的"""+str2+"""归算坐标。</span></p></body></html>"""
|
817
|
|
- # self.ui.printTableView.setHtml(str0)
|
818
|
|
- #
|
819
|
|
- # # 计算结束自动跳转结果页面,并保留查询内容,以便输出
|
820
|
|
- # widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
|
821
|
|
- # UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
|
822
|
|
- # btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
|
823
|
|
- # # GS.main_function(file_path, db_path)
|
824
|
|
- # # 添加控制网执行代码
|
825
|
|
- # elif current_text=="平面控制网稳定性计算":
|
826
|
|
- # #只显示头两个tab
|
827
|
|
- # self.ui.tabWidget.setTabVisible(0,True)
|
828
|
|
- # self.ui.tabWidget.setTabVisible(1,True)
|
829
|
|
- # self.ui.tabWidget.setTabVisible(2,False)
|
830
|
|
- # #重新设置文字名称
|
831
|
|
- # self.ui.tabWidget.setTabText(0,'稳定性分析成果表')
|
832
|
|
- # self.ui.tabWidget.setTabText(1,'自由网成果归算模型')
|
833
|
|
- # #链接数据库并显示
|
834
|
|
- # # 连接到数据库
|
835
|
|
- # #将结果输出到数据库
|
836
|
|
- # db1 = sqlite3.connect(db_path)
|
837
|
|
- # #获取游标
|
838
|
|
- # cursor1 = db1.cursor()
|
839
|
|
- # #查询表内符合的所有数据
|
840
|
|
- # sqlstr1 = 'select PointName,First_X,First_Y,Last_X,Last_Y,Last_Wight,Result_X,Result_Y,New_Wight,New_FirstX,New_FirstY,New_FirstP,NFDis_Ass,New_LastX,New_LastY,New_LastP,NLDis_Ass from WD_Result_Point WHERE TableName = ?'
|
841
|
|
- # cursor1.execute(sqlstr1,(utf_en,))
|
842
|
|
- # #获取结果集
|
843
|
|
- # result = cursor1.fetchall()
|
844
|
|
- # #对结果集进行处理,把汉字转换过来,添加表头部分
|
845
|
|
- # nlist,plist = self.Arrange_Data(result)
|
846
|
|
- # # 创建一个数据模型
|
847
|
|
- # self.model = QStandardItemModel()
|
848
|
|
- # #把数据放进去
|
849
|
|
- # model1 = self.Data_in_Cell(plist)
|
850
|
|
- # #设置表头
|
851
|
|
- # model1.setHorizontalHeaderLabels(['点名', '首期X','首期Y','上期X', '上期Y','权','本期X','本期Y','权','本期-首期X','本期-首期Y','本期-首期P','位移判定', '本期-上期X','本期-上期Y','本期-上期P','位移判定'])
|
852
|
|
- # model1.setVerticalHeaderLabels(nlist)
|
853
|
|
- # #QTableView并将数据模型与之关联
|
854
|
|
- # self.ui.resultTableView.setModel(model1)
|
855
|
|
- # self.ui.resultTableView.show()
|
856
|
|
- #
|
857
|
|
- # #富文本的html
|
858
|
|
- # sqlstr2 = 'select Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3 from WD_Result_Param WHERE TableName = ?'
|
859
|
|
- # cursor1.execute(sqlstr2,(utf_en,))
|
860
|
|
- # #获取结果集
|
861
|
|
- # result1 = cursor1.fetchall()
|
862
|
|
- # str1 = result1[0][0].decode('utf-8')
|
863
|
|
- # str2 = result1[0][1].decode('utf-8')
|
864
|
|
- # n1 = result1[0][2]
|
865
|
|
- # n2 = result1[0][3]
|
866
|
|
- # n3 = result1[0][4]
|
867
|
|
- # n4 = result1[0][5]
|
868
|
|
- # n5 = result1[0][6]
|
869
|
|
- # n6 = result1[0][7]
|
870
|
|
- # str0 = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
871
|
|
- # <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
872
|
|
- # p, li { white-space: pre-wrap; }
|
873
|
|
- # hr { height: 1px; border-width: 0; }
|
874
|
|
- # li.unchecked::marker { content: "\2610"; }
|
875
|
|
- # li.checked::marker { content: "\2612"; }
|
876
|
|
- # </style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
877
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; color:#000000;">"""+str2+"""--"""+str1+"""</span><span style=" font-size:14pt;">已知系统转换公式:</span></p>
|
878
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">X</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n1)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n2)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n3)+"""</span><span style=" font-size:14pt;">)</span></p>
|
879
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">Y</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n4)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n5)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n6)+"""</span><span style=" font-size:14pt;">)</span></p>
|
880
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">式中:</span><span style=" font-size:14pt; font-weight:700; color:#000000;">x、y</span><span style=" font-size:14pt;">为</span><span style=" font-size:14pt; color:#000000;">"""+str2+"""</span><span style=" font-size:14pt;">坐标;</span></p>
|
881
|
|
- # <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;"> </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为"""+str1+"""已知系统的"""+str2+"""归算坐标。</span></p></body></html>"""
|
882
|
|
- # self.ui.printTableView.setHtml(str0)
|
883
|
|
- #
|
884
|
|
-# #----------------------------------------------------------
|
885
|
|
-# # 计算结束自动跳转结果页面,并保留查询内容,以便输出
|
886
|
|
-# widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
|
887
|
|
-# UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
|
888
|
|
-# btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
|
889
|
|
-
|
890
|
|
-
|
891
|
|
- # 点击事件
|
892
|
|
- # 在这里添加点击事件的方法
|
893
|
|
- # ///////////////////////////////////////////////////////////////
|
894
|
|
- def buttonClick(self):
|
895
|
|
- # GET BUTTON CLICKED
|
896
|
|
- btn = self.sender()
|
897
|
|
- btnName = btn.objectName()
|
898
|
|
-
|
899
|
|
- # 首页
|
900
|
|
- if btnName == "btn_home":
|
901
|
|
- widgets.stackedWidget.setCurrentWidget(widgets.home)
|
902
|
|
- UIFunctions.resetStyle(self, btnName)
|
903
|
|
- btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
|
904
|
|
-
|
905
|
|
- # 输入表格
|
906
|
|
- if btnName == "btn_widgets":
|
907
|
|
- widgets.stackedWidget.setCurrentWidget(widgets.widgets)
|
908
|
|
- UIFunctions.resetStyle(self, btnName)
|
909
|
|
- btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
|
910
|
|
-
|
911
|
|
- # 成果预览
|
912
|
|
- if btnName == "btn_new":
|
913
|
|
- widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
|
914
|
|
- UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
|
915
|
|
- btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
|
916
|
|
-
|
917
|
|
- # 数据一览
|
918
|
|
- if btnName == "btn_data":
|
919
|
|
- widgets.stackedWidget.setCurrentWidget(widgets.datainfo) # SET PAGE
|
920
|
|
- UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
|
921
|
|
- btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
|
922
|
|
-
|
923
|
|
- # 皮肤切换
|
924
|
|
- if btnName == "btn_message":
|
925
|
|
- if self.useCustomTheme:
|
926
|
|
- themeFile = os.path.abspath(os.path.join(self.absPath, "themes/py_dracula_dark.qss"))
|
927
|
|
- UIFunctions.theme(self, themeFile, True)
|
928
|
|
- # SET HACKS
|
929
|
|
- AppFunctions.setThemeHack(self)
|
930
|
|
- self.useCustomTheme = False
|
931
|
|
- else:
|
932
|
|
- themeFile = os.path.abspath(os.path.join(self.absPath, "themes/py_dracula_light.qss"))
|
933
|
|
- UIFunctions.theme(self, themeFile, True)
|
934
|
|
- # SET HACKS
|
935
|
|
- AppFunctions.setThemeHack(self)
|
936
|
|
- self.useCustomTheme = True
|
937
|
|
- # 文件上传
|
938
|
|
- if btnName == "upload":
|
939
|
|
- global file_path
|
940
|
|
- # options = QFileDialog.Options()
|
941
|
|
- # 使用 QFileDialog 获取文件路径
|
942
|
|
- file_path, _ = QFileDialog.getOpenFileName(
|
943
|
|
- self,
|
944
|
|
- "选择文件",
|
945
|
|
- "",
|
946
|
|
- "表格文件 (*.xls *.xlsx)"
|
947
|
|
- )
|
948
|
|
- if file_path:
|
949
|
|
- # 处理选中的文件
|
950
|
|
- # print(file_path)
|
951
|
|
- UIFunctions.execute_script_based_on_selection(self, file_path)
|
952
|
|
-
|
953
|
|
- # messagebox.showinfo("提示",f"文件 '{file_name}' 跳转成功!")
|
954
|
|
- # 输出点击回馈
|
955
|
|
- print(f'Button "{btnName}" pressed!')
|
956
|
|
-
|
957
|
|
- # RESIZE EVENTS
|
958
|
|
- # ///////////////////////////////////////////////////////////////
|
959
|
|
- def resizeEvent(self, event):
|
960
|
|
- # Update Size Grips
|
961
|
|
- UIFunctions.resize_grips(self)
|
962
|
|
-
|
963
|
|
- # 鼠标点击事件
|
964
|
|
- # ///////////////////////////////////////////////////////////////
|
965
|
|
- def mousePressEvent(self, event):
|
966
|
|
- # SET DRAG POS WINDOW
|
967
|
|
- self.dragPos = event.globalPos()
|
968
|
|
-
|
969
|
|
- # 输出鼠标事件
|
970
|
|
- if event.buttons() == Qt.LeftButton:
|
971
|
|
- print('Mouse click: LEFT CLICK')
|
972
|
|
- if event.buttons() == Qt.RightButton:
|
973
|
|
- print('Mouse click: RIGHT CLICK')
|
974
|
|
-
|
975
|
|
-
|
976
|
|
-if __name__ == "__main__":
|
977
|
|
- app = QApplication(sys.argv)
|
978
|
|
- app.setWindowIcon(QIcon("icon.ico"))
|
979
|
|
- window = MainWindow()
|
980
|
|
- # window.resize(1440, 960) # 高宽
|
981
|
|
- sys.exit(app.exec())
|