示例#1
0
    def buttonOpenClicked(self):
        fileDialog = QFileDialog(
            self, "打开历史数据文件", QApplication.applicationDirPath() + "/../data", "Database File (*.db *.mdb)"
        )
        if fileDialog.exec_() == QDialog.Rejected:
            return
        # clear curve
        self.curveHistory.clear()
        #
        filePaths = fileDialog.selectedFiles()
        if filePaths.isEmpty():
            return
        filePath = filePaths.first()
        if filePath.isEmpty():
            return
        # open database
        if not DatabaseMgr().open(filePath):
            return
        #
        startTime = QDateTime.fromMSecsSinceEpoch(DatabaseMgr().startTime())
        endTime = QDateTime.fromMSecsSinceEpoch(DatabaseMgr().endTime())
        self.dateTimeEditStart.setDateTimeRange(startTime, endTime)
        self.dateTimeEditEnd.setDateTimeRange(startTime, endTime)
        self.dateTimeEditEnd.setDateTime(endTime)
        self.dateTimeEditStart.setDateTime(startTime)

        # title of curve
        self.curveHistory.setTitle("历史数据回放" + "(" + QFileInfo(filePath).fileName() + ")")
示例#2
0
 def buttonExportClicked(self):
     (filePaths, filter) = QFileDialog.getOpenFileNames(
         parent=self,
         caption="转换数据库文件为文本格式",
         directory=QApplication.applicationDirPath() + "/../data",
         filter="Database file (*.db * mdb)",
     )
     if not filePaths:
         return
     #
     if DatabaseMgr().convertToText(filePaths):
         QMessageBox.information(self, "格式转换", "转换成功!")
     else:
         QMessageBox.warning(self, "格式转换", "转换失败!")