Example #1
0
 def searchButtonClicked(self):
     f = FETCH()
     try:
         if self.searchEdit.text() == "":
             self.init_data = f.fetch_backtest_history()
             self.totalRecord = len(self.init_data)
             self.totalPage = self.totalRecord // 10 + 1
             self.currentPage = 1
             self.pageLabel.setText("/" + str(self.totalPage) + "页")
             self.updateQueryModel()
         elif self.condisionComboBox.currentText() == "按回测编号查找":
             self.init_data = f.fuzzy_fetch_backtest_history(
                 self.searchEdit.text(), "ac_id")
             self.totalRecord = len(self.init_data)
             self.totalPage = self.totalRecord // 10 + 1
             self.currentPage = 1
             self.pageLabel.setText("/" + str(self.totalPage) + "页")
             self.updateQueryModel()
         elif self.condisionComboBox.currentText() == "按回测类型查找":
             self.init_data = f.fuzzy_fetch_backtest_history(
                 self.searchEdit.text(), "type")
             self.totalRecord = len(self.init_data)
             self.totalPage = self.totalRecord // 10 + 1
             self.currentPage = 1
             self.pageLabel.setText("/" + str(self.totalPage) + "页")
             self.updateQueryModel()
     except KeyError:
         print(
             QMessageBox.warning(self, "警告", "没有记录与之匹配", QMessageBox.Yes,
                                 QMessageBox.Yes))
Example #2
0
    def initUI(self):
        f = FETCH()
        self.init_data = f.fetch_backtest_history()
        self.totalRecord = len(self.init_data)
        self.totalPage = self.totalRecord // 10 + 1
        self.vbox = QVBoxLayout()
        self.h1box = QHBoxLayout()
        self.h2box = QHBoxLayout()

        self.searchEdit = QLineEdit()
        self.searchEdit.setFixedHeight(32)
        self.searchEdit.setFont(QFont("仿宋", 15))

        self.searchButton = QPushButton("查询")
        self.searchButton.setFixedHeight(32)
        self.searchButton.setFont(QFont("仿宋", 15))

        self.condisionComboBox = QComboBox()
        searchCondision = ["按回测编号查找", "按回测类型查找"]
        self.condisionComboBox.setFixedHeight(32)
        self.condisionComboBox.setFont(QFont("仿宋", 15))
        self.condisionComboBox.addItems(searchCondision)

        self.h1box.addWidget(self.searchEdit)
        self.h1box.addWidget(self.condisionComboBox)
        self.h1box.addWidget(self.searchButton)

        self.currentPageLabel = QLabel(self)
        self.currentPageLabel.setFixedWidth(140)
        self.currentPageLabel.setFont(QFont("仿宋", 12))

        self.jumpToLabel = QLabel(self)
        self.jumpToLabel.setText("跳转到第")
        self.jumpToLabel.setFont(QFont("仿宋", 12))
        self.jumpToLabel.setFixedWidth(90)
        self.pageEdit = QLineEdit()
        self.pageEdit.setFixedWidth(30)
        self.pageEdit.setFont(QFont("仿宋", 12))
        self.pageLabel = QLabel(self)
        self.pageLabel.setText("/" + str(self.totalPage) + "页")
        self.pageLabel.setFont(QFont("仿宋", 12))
        self.pageLabel.setFixedWidth(60)
        self.jumpToButton = QPushButton(self)
        self.jumpToButton.setText("跳转")
        self.jumpToButton.setFont(QFont("仿宋", 12))
        self.jumpToButton.setFixedHeight(30)
        self.jumpToButton.setFixedWidth(60)
        self.prevButton = QPushButton("前一页")
        self.prevButton.setFont(QFont("仿宋", 12))
        self.prevButton.setFixedHeight(30)
        self.prevButton.setFixedWidth(80)
        self.backButton = QPushButton("后一页")
        self.backButton.setFont(QFont("仿宋", 12))
        self.backButton.setFixedHeight(30)
        self.backButton.setFixedWidth(80)
        self.prevButton.clicked.connect(self.prevButtonClicked)
        self.backButton.clicked.connect(self.backButtonClicked)
        self.jumpToButton.clicked.connect(self.jumpToButtonClicked)
        self.searchButton.clicked.connect(self.searchButtonClicked)

        self.detailbutton = QPushButton(self)
        self.detailbutton.setText("详细信息")
        self.detailbutton.setFixedWidth(90)
        self.detailbutton.setFont(QFont("仿宋", 12))
        self.detailbutton.clicked.connect(self.detailInfo)

        self.hbox = QHBoxLayout()
        self.hbox.addWidget(self.currentPageLabel)
        self.hbox.addStretch(1)
        self.hbox.addWidget(self.jumpToLabel)
        self.hbox.addWidget(self.pageEdit)
        self.hbox.addWidget(self.pageLabel)
        self.hbox.addWidget(self.jumpToButton)
        self.hbox.addStretch(1)
        self.hbox.addWidget(self.detailbutton)
        self.hbox.addStretch(1)
        self.hbox.addWidget(self.prevButton)
        self.hbox.addWidget(self.backButton)
        widget = QWidget()
        widget.setLayout(self.hbox)
        self.h2box.addWidget(widget)

        self.tableView = QTableView()

        self.tableView.horizontalHeader().setStretchLastSection(True)
        # self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.tableView.horizontalHeader().setSectionResizeMode(
            QHeaderView.Interactive)
        self.tableView.verticalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        self.tableView.verticalHeader().setSectionResizeMode(
            0, QHeaderView.ResizeToContents)
        self.tableView.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tableView.setFont(QFont("仿宋", 10))
        self.tableView.horizontalHeader().setFont(QFont("仿宋", 12))

        self.queryModel = QStandardItemModel(self.pageRecord, 2)
        self.updateQueryModel()

        self.vbox.addLayout(self.h1box)
        self.vbox.addWidget(self.tableView)
        self.vbox.addLayout(self.h2box)
        self.setLayout(self.vbox)