控制网复测平面基准归算程序(包含控制网复测平面基准计算,平面控制网稳定性计算,水准测段高差稳定计算三个程序功能)
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. import time
  17. from PySide6.QtWidgets import QFileDialog
  18. import sys
  19. import os
  20. import platform
  21. # IMPORT / GUI AND MODULES AND WIDGETS
  22. # ///////////////////////////////////////////////////////////////
  23. from modules import *
  24. from widgets import *
  25. os.environ["QT_FONT_DPI"] = "96" # FIX Problem for High DPI and Scale above 100%
  26. # SET AS GLOBAL WIDGETS
  27. # ///////////////////////////////////////////////////////////////
  28. widgets = None
  29. # 表格的模型
  30. class MyTableModel(QAbstractTableModel):
  31. def __init__(self, data):
  32. super().__init__()
  33. self._data = data
  34. # 重新定义行数
  35. def rowCount(self, parent=QModelIndex()):
  36. return len(self._data)
  37. # 重新定义列数
  38. def columnCount(self, parent=QModelIndex()):
  39. return len(self._data[0]) if self._data else 0
  40. # 重新定义数据
  41. def data(self, index, role=Qt.DisplayRole):
  42. if not index.isValid():
  43. return None
  44. if role == Qt.DisplayRole:
  45. return self._data[index.row()][index.column()]
  46. return None
  47. class MainWindow(QMainWindow):
  48. def __init__(self):
  49. QMainWindow.__init__(self)
  50. self.file_path = None # 初始化时文件路径设置为None
  51. # super().__init__()
  52. # SET AS GLOBAL WIDGETS
  53. # ///////////////////////////////////////////////////////////////
  54. self.ui = Ui_MainWindow()
  55. self.ui.setupUi(self)
  56. # self.comboBox_2 = QComboBox(self)
  57. # ...此处为省略代码...
  58. global widgets
  59. widgets = self.ui
  60. # 是否使用系统自带标题栏 True是不使用,False使用
  61. # ///////////////////////////////////////////////////////////////
  62. Settings.ENABLE_CUSTOM_TITLE_BAR = True
  63. # APP名称
  64. # ///////////////////////////////////////////////////////////////
  65. title = "控制网复测平面基准归算程序"
  66. description = "控制网复测平面基准归算程序"
  67. # APPLY TEXTS
  68. self.setWindowTitle(title)
  69. widgets.titleRightInfo.setText(description)
  70. # TOGGLE MENU
  71. # ///////////////////////////////////////////////////////////////
  72. widgets.toggleButton.clicked.connect(lambda: UIFunctions.toggleMenu(self, True))
  73. # SET UI DEFINITIONS
  74. # ///////////////////////////////////////////////////////////////
  75. UIFunctions.uiDefinitions(self)
  76. # QTableWidget PARAMETERS
  77. # ///////////////////////////////////////////////////////////////
  78. # widgets.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
  79. # 点击事件
  80. # ///////////////////////////////////////////////////////////////
  81. # 左边菜单
  82. # 首页
  83. widgets.btn_home.clicked.connect(self.buttonClick)
  84. # 输入表格
  85. widgets.btn_widgets.clicked.connect(self.buttonClick)
  86. # 成果预览
  87. widgets.btn_new.clicked.connect(self.buttonClick)
  88. # 数据一览
  89. widgets.btn_data.clicked.connect(self.buttonClick)
  90. # 皮肤切换
  91. widgets.btn_message.clicked.connect(self.buttonClick)
  92. # 打开上传文件夹
  93. widgets.upload.clicked.connect(self.buttonClick)
  94. # 文件计算
  95. widgets.compute.clicked.connect(self.buttonClick)
  96. # 拓展左侧栏
  97. # def openCloseLeftBox():
  98. # UIFunctions.toggleLeftBox(self, True)
  99. # widgets.toggleLeftBox.clicked.connect(openCloseLeftBox)
  100. # widgets.extraCloseColumnBtn.clicked.connect(openCloseLeftBox)
  101. # EXTRA RIGHT BOX
  102. def openCloseRightBox():
  103. UIFunctions.toggleRightBox(self, True)
  104. widgets.settingsTopBtn.clicked.connect(openCloseRightBox)
  105. # 展示APP
  106. # ///////////////////////////////////////////////////////////////
  107. self.show()
  108. # 设置主题
  109. # ///////////////////////////////////////////////////////////////
  110. if getattr(sys, 'frozen', False):
  111. absPath = os.path.dirname(os.path.abspath(sys.executable))
  112. elif __file__:
  113. absPath = os.path.dirname(os.path.abspath(__file__))
  114. useCustomTheme = True
  115. self.useCustomTheme = useCustomTheme
  116. self.absPath = absPath
  117. themeFile = r"themes\py_dracula_light.qss"
  118. # 设置主题和HACKS
  119. if useCustomTheme:
  120. # LOAD AND APPLY STYLE
  121. UIFunctions.theme(self, themeFile, True)
  122. # SET HACKS
  123. AppFunctions.setThemeHack(self)
  124. # 设置主页和选择菜单
  125. # ///////////////////////////////////////////////////////////////
  126. widgets.stackedWidget.setCurrentWidget(widgets.home)
  127. widgets.btn_home.setStyleSheet(UIFunctions.selectMenu(widgets.btn_home.styleSheet()))
  128. # self.bind()
  129. # 绑定组件
  130. def bind(self):
  131. # 计算
  132. widgets.compute.clicked.connect(self.buttonClick)
  133. # 删除tableview
  134. def delete_table_view(table_view):
  135. table_view.setParent(None)
  136. table_view.deleteLater()
  137. # ///////////////////////////////////////////////////////////////
  138. def buttonClick(self):
  139. # GET BUTTON CLICKED
  140. btn = self.sender()
  141. btnName = btn.objectName()
  142. # 首页
  143. if btnName == "btn_home":
  144. widgets.stackedWidget.setCurrentWidget(widgets.home)
  145. UIFunctions.resetStyle(self, btnName)
  146. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
  147. # 输入表格
  148. if btnName == "btn_widgets":
  149. widgets.stackedWidget.setCurrentWidget(widgets.widgets)
  150. UIFunctions.resetStyle(self, btnName)
  151. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
  152. # 成果预览
  153. if btnName == "btn_new":
  154. widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
  155. UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
  156. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
  157. # 数据一览
  158. if btnName == "btn_data":
  159. widgets.stackedWidget.setCurrentWidget(widgets.datainfo) # SET PAGE
  160. UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
  161. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
  162. # 皮肤切换
  163. if btnName == "btn_message":
  164. if self.useCustomTheme:
  165. themeFile = os.path.abspath(os.path.join(self.absPath, "themes/py_dracula_dark.qss"))
  166. UIFunctions.theme(self, themeFile, True)
  167. # SET HACKS
  168. AppFunctions.setThemeHack(self)
  169. self.useCustomTheme = False
  170. else:
  171. themeFile = os.path.abspath(os.path.join(self.absPath, "themes/py_dracula_light.qss"))
  172. UIFunctions.theme(self, themeFile, True)
  173. # SET HACKS
  174. AppFunctions.setThemeHack(self)
  175. self.useCustomTheme = True
  176. # 文件上传
  177. if btnName == "upload":
  178. # 使用 QFileDialog 获取文件路径
  179. file_path, _ = QFileDialog.getOpenFileName(
  180. self,
  181. "选择文件",
  182. "",
  183. "表格文件 (*.xls *.xlsx)"
  184. # 水准后期添加支持.xls文件
  185. )
  186. if file_path:
  187. # 处理选中的文件
  188. self.file_path = file_path # 将获取的路径保存到类的属性中
  189. UIFunctions.execute_script_based_on_selection(self, file_path)
  190. # 文件计算
  191. if btnName == "compute":
  192. if self.file_path: # 确保有文件路径后再进行处理
  193. # 计算与展示的业务代码
  194. UIFunctions.compute_show_process_excel_file(self, self.file_path)
  195. # 1秒后自动跳转
  196. QTimer.singleShot(1000, lambda: self.simulateButtonClick("btn_new"))
  197. else:
  198. QMessageBox.warning(self, '警告', '请先上传文件到本地数据库中')
  199. # 输出点击回馈
  200. print(f'Button "{btnName}" pressed!')
  201. # 辅助函数,点击计算后自动跳转页面
  202. def simulateButtonClick(self, btnName):
  203. # 根据按钮名称找到对应的按钮
  204. btn = self.findChild(QObject, btnName)
  205. if btn:
  206. # 触发按钮点击事件
  207. btn.click()
  208. # RESIZE EVENTS
  209. # ///////////////////////////////////////////////////////////////
  210. def resizeEvent(self, event):
  211. # Update Size Grips
  212. UIFunctions.resize_grips(self)
  213. # 鼠标点击事件
  214. # ///////////////////////////////////////////////////////////////
  215. def mousePressEvent(self, event):
  216. # SET DRAG POS WINDOW
  217. # self.dragPos = event.globalPos()
  218. self.dragPos = event.globalPosition().toPoint()
  219. # 输出鼠标事件
  220. if event.buttons() == Qt.LeftButton:
  221. print('Mouse click: LEFT CLICK')
  222. if event.buttons() == Qt.RightButton:
  223. print('Mouse click: RIGHT CLICK')
  224. if __name__ == "__main__":
  225. app = QApplication(sys.argv)
  226. app.setWindowIcon(QIcon("icon.ico"))
  227. window = MainWindow()
  228. # window.resize(1440, 960) # 高宽
  229. sys.exit(app.exec_())