def main(url): # This function is run in a separate process and can do anything it likes, # including use QWebEngine. Here it simply opens the passed in URL # in a QWebEngineView app = Application([]) w = QWebEngineView() w.setUrl(QUrl(url)) w.show() w.raise_() app.exec_()
def show_qt(fig): raw_html = '<html><head><meta charset="utf-8" />' raw_html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>' raw_html += '<body>' raw_html += py.offline.plot(fig, include_plotlyjs=False, output_type='div') raw_html += '</body></html>' fig_view = QWebEngineView() fig_view.setHtml(raw_html) fig_view.show() fig_view.raise_() return fig_view
def show_qt(fig): raw_html = '<html><head><meta charset="utf-8" />' raw_html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>' raw_html += '<body>' raw_html += po.plot(fig, include_plotlyjs=False, output_type='div') raw_html += '</body></html>' fig_view = QWebEngineView() # setHtml has a 2MB size limit, need to switch to setUrl on tmp file # for large figures. fig_view.setHtml(raw_html) fig_view.show() fig_view.raise_() return fig_view
def show_qt(fig): # <-- treated as another button raw_html = '<html><head><meta charset="utf-8" />' raw_html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>' raw_html += '<body>' raw_html += po.plot(fig, include_plotlyjs=False, output_type='div') # 'div'for embedding graphs in an HTML file with other graphs or HTML markup raw_html += '</body></html>' fig_view = QWebEngineView() # setHtml has a 2MB size limit, need to switch to setUrl on tmp file # for large figures. fig_view.setHtml(raw_html) fig_view.show() # <-- only show in window fig_view.raise_() return fig_view
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setEnabled(True) MainWindow.resize(913, 971) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(3) sizePolicy.setVerticalStretch(33) sizePolicy.setHeightForWidth( MainWindow.sizePolicy().hasHeightForWidth()) MainWindow.setSizePolicy(sizePolicy) MainWindow.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) MainWindow.setAutoFillBackground(True) MainWindow.setStyleSheet("") MainWindow.setAnimated(True) self.centralWidget = QtWidgets.QWidget(MainWindow) self.centralWidget.setObjectName("centralWidget") self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.centralWidget) self.verticalLayout_5.setObjectName("verticalLayout_5") self.tabWidget_PGMS = QtWidgets.QTabWidget(self.centralWidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(20) sizePolicy.setVerticalStretch(44) sizePolicy.setHeightForWidth( self.tabWidget_PGMS.sizePolicy().hasHeightForWidth()) self.tabWidget_PGMS.setSizePolicy(sizePolicy) self.tabWidget_PGMS.setMinimumSize(QtCore.QSize(800, 700)) self.tabWidget_PGMS.setLayoutDirection(QtCore.Qt.LeftToRight) self.tabWidget_PGMS.setAutoFillBackground(True) self.tabWidget_PGMS.setStyleSheet("") self.tabWidget_PGMS.setTabBarAutoHide(True) self.tabWidget_PGMS.setObjectName("tabWidget_PGMS") self.tab_Combination = QtWidgets.QWidget() self.tab_Combination.setObjectName("tab_Combination") self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.tab_Combination) self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.scrollArea_3 = QtWidgets.QScrollArea(self.tab_Combination) self.scrollArea_3.setWidgetResizable(True) self.scrollArea_3.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.scrollArea_3.setObjectName("scrollArea_3") self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() self.scrollAreaWidgetContents_3.setGeometry( QtCore.QRect(0, 0, 852, 958)) self.scrollAreaWidgetContents_3.setObjectName( "scrollAreaWidgetContents_3") self.verticalLayout_8 = QtWidgets.QVBoxLayout( self.scrollAreaWidgetContents_3) self.verticalLayout_8.setContentsMargins(0, 0, 0, 0) self.verticalLayout_8.setObjectName("verticalLayout_8") self.verticalLayout_6 = QtWidgets.QVBoxLayout() self.verticalLayout_6.setObjectName("verticalLayout_6") self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setObjectName("horizontalLayout_3") spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem) self.verticalLayout_7 = QtWidgets.QVBoxLayout() self.verticalLayout_7.setObjectName("verticalLayout_7") self.label_7 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_7.setText("") self.label_7.setObjectName("label_7") self.verticalLayout_7.addWidget(self.label_7) self.label_10 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_10.sizePolicy().hasHeightForWidth()) self.label_10.setSizePolicy(sizePolicy) self.label_10.setObjectName("label_10") self.verticalLayout_7.addWidget(self.label_10) self.label_11 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_11.setObjectName("label_11") self.verticalLayout_7.addWidget(self.label_11) self.label_12 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_12.setObjectName("label_12") self.verticalLayout_7.addWidget(self.label_12) self.horizontalLayout_3.addLayout(self.verticalLayout_7) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.horizontalLayout_3.addItem(spacerItem1) self.gridLayout_5 = QtWidgets.QGridLayout() self.gridLayout_5.setObjectName("gridLayout_5") self.label_8 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_8.setObjectName("label_8") self.gridLayout_5.addWidget(self.label_8, 0, 0, 1, 1) self.label_9 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_9.setObjectName("label_9") self.gridLayout_5.addWidget(self.label_9, 0, 1, 1, 1) self.doubleSpinBox_returns_min = QtWidgets.QDoubleSpinBox( self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.doubleSpinBox_returns_min.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_returns_min.setSizePolicy(sizePolicy) self.doubleSpinBox_returns_min.setMaximum(0.3) self.doubleSpinBox_returns_min.setSingleStep(0.01) self.doubleSpinBox_returns_min.setProperty("value", 0.0) self.doubleSpinBox_returns_min.setObjectName( "doubleSpinBox_returns_min") self.gridLayout_5.addWidget(self.doubleSpinBox_returns_min, 1, 0, 1, 1) self.doubleSpinBox_returns_max = QtWidgets.QDoubleSpinBox( self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.doubleSpinBox_returns_max.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_returns_max.setSizePolicy(sizePolicy) self.doubleSpinBox_returns_max.setMinimum(0.0) self.doubleSpinBox_returns_max.setMaximum(10.0) self.doubleSpinBox_returns_max.setSingleStep(0.1) self.doubleSpinBox_returns_max.setProperty("value", 0.0) self.doubleSpinBox_returns_max.setObjectName( "doubleSpinBox_returns_max") self.gridLayout_5.addWidget(self.doubleSpinBox_returns_max, 1, 1, 1, 1) self.doubleSpinBox_maxdrawdown_min = QtWidgets.QDoubleSpinBox( self.scrollAreaWidgetContents_3) self.doubleSpinBox_maxdrawdown_min.setMinimum(0.1) self.doubleSpinBox_maxdrawdown_min.setMaximum(1.0) self.doubleSpinBox_maxdrawdown_min.setSingleStep(0.01) self.doubleSpinBox_maxdrawdown_min.setProperty("value", 0.7) self.doubleSpinBox_maxdrawdown_min.setObjectName( "doubleSpinBox_maxdrawdown_min") self.gridLayout_5.addWidget(self.doubleSpinBox_maxdrawdown_min, 2, 0, 1, 1) self.doubleSpinBox_maxdrawdown_max = QtWidgets.QDoubleSpinBox( self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.doubleSpinBox_maxdrawdown_max. sizePolicy().hasHeightForWidth()) self.doubleSpinBox_maxdrawdown_max.setSizePolicy(sizePolicy) self.doubleSpinBox_maxdrawdown_max.setMinimum(0.2) self.doubleSpinBox_maxdrawdown_max.setMaximum(1.0) self.doubleSpinBox_maxdrawdown_max.setSingleStep(0.01) self.doubleSpinBox_maxdrawdown_max.setProperty("value", 1.0) self.doubleSpinBox_maxdrawdown_max.setObjectName( "doubleSpinBox_maxdrawdown_max") self.gridLayout_5.addWidget(self.doubleSpinBox_maxdrawdown_max, 2, 1, 1, 1) self.doubleSpinBox_sharp_min = QtWidgets.QDoubleSpinBox( self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.doubleSpinBox_sharp_min.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_sharp_min.setSizePolicy(sizePolicy) self.doubleSpinBox_sharp_min.setMaximum(40.0) self.doubleSpinBox_sharp_min.setSingleStep(0.05) self.doubleSpinBox_sharp_min.setObjectName("doubleSpinBox_sharp_min") self.gridLayout_5.addWidget(self.doubleSpinBox_sharp_min, 3, 0, 1, 1) self.doubleSpinBox_sharp_max = QtWidgets.QDoubleSpinBox( self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.doubleSpinBox_sharp_max.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_sharp_max.setSizePolicy(sizePolicy) self.doubleSpinBox_sharp_max.setProperty("value", 10.0) self.doubleSpinBox_sharp_max.setObjectName("doubleSpinBox_sharp_max") self.gridLayout_5.addWidget(self.doubleSpinBox_sharp_max, 3, 1, 1, 1) self.horizontalLayout_3.addLayout(self.gridLayout_5) self.line_2 = QtWidgets.QFrame(self.scrollAreaWidgetContents_3) self.line_2.setFrameShape(QtWidgets.QFrame.VLine) self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_2.setObjectName("line_2") self.horizontalLayout_3.addWidget(self.line_2) spacerItem2 = QtWidgets.QSpacerItem(200, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem2) self.pushButton_start_combination = QtWidgets.QPushButton( self.scrollAreaWidgetContents_3) self.pushButton_start_combination.setObjectName( "pushButton_start_combination") self.horizontalLayout_3.addWidget(self.pushButton_start_combination) spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem3) self.verticalLayout_6.addLayout(self.horizontalLayout_3) self.horizontalLayout_7 = QtWidgets.QHBoxLayout() self.horizontalLayout_7.setObjectName("horizontalLayout_7") self.checkBox_stock = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_stock.setObjectName("checkBox_stock") self.horizontalLayout_7.addWidget(self.checkBox_stock) self.checkBox_compound = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_compound.setObjectName("checkBox_compound") self.horizontalLayout_7.addWidget(self.checkBox_compound) self.checkBox_future_manage = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_future_manage.setObjectName("checkBox_future_manage") self.horizontalLayout_7.addWidget(self.checkBox_future_manage) self.checkBox_event = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_event.setObjectName("checkBox_event") self.horizontalLayout_7.addWidget(self.checkBox_event) self.checkBox_bond = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_bond.setObjectName("checkBox_bond") self.horizontalLayout_7.addWidget(self.checkBox_bond) self.checkBox_macro = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_macro.setObjectName("checkBox_macro") self.horizontalLayout_7.addWidget(self.checkBox_macro) self.checkBox_combination_fund = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_combination_fund.setObjectName( "checkBox_combination_fund") self.horizontalLayout_7.addWidget(self.checkBox_combination_fund) self.checkBox_relative_fund = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_relative_fund.setObjectName("checkBox_relative_fund") self.horizontalLayout_7.addWidget(self.checkBox_relative_fund) self.checkBox_others = QtWidgets.QCheckBox( self.scrollAreaWidgetContents_3) self.checkBox_others.setObjectName("checkBox_others") self.horizontalLayout_7.addWidget(self.checkBox_others) self.verticalLayout_6.addLayout(self.horizontalLayout_7) self.verticalLayout_8.addLayout(self.verticalLayout_6) self.QWebEngineview_Combination_monte_markovitz = QWebEngineView( self.scrollAreaWidgetContents_3) self.QWebEngineview_Combination_monte_markovitz.setMinimumSize( QtCore.QSize(0, 300)) self.QWebEngineview_Combination_monte_markovitz.setStyleSheet( "background-color: rgb(170, 170, 127);") self.QWebEngineview_Combination_monte_markovitz.setObjectName( "QWebEngineview_Combination_monte_markovitz") self.verticalLayout_8.addWidget( self.QWebEngineview_Combination_monte_markovitz) self.horizontalLayout_5 = QtWidgets.QHBoxLayout() self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.QWebEngineview_Combination_Pie = QWebEngineView( self.scrollAreaWidgetContents_3) self.QWebEngineview_Combination_Pie.setMinimumSize( QtCore.QSize(50, 200)) self.QWebEngineview_Combination_Pie.setStyleSheet( "background-color: rgb(170, 170, 127);") self.QWebEngineview_Combination_Pie.setObjectName( "QWebEngineview_Combination_Pie") self.horizontalLayout_5.addWidget(self.QWebEngineview_Combination_Pie) self.QWebEngineview_Combination_Table = QWebEngineView( self.scrollAreaWidgetContents_3) self.QWebEngineview_Combination_Table.setMinimumSize( QtCore.QSize(0, 200)) self.QWebEngineview_Combination_Table.setStyleSheet( "background-color: rgb(170, 170, 127);") self.QWebEngineview_Combination_Table.setObjectName( "QWebEngineview_Combination_Table") self.horizontalLayout_5.addWidget( self.QWebEngineview_Combination_Table) self.verticalLayout_8.addLayout(self.horizontalLayout_5) self.QWebEngineview_Combination_Versus = QWebEngineView( self.scrollAreaWidgetContents_3) self.QWebEngineview_Combination_Versus.setEnabled(True) self.QWebEngineview_Combination_Versus.setMinimumSize( QtCore.QSize(0, 300)) self.QWebEngineview_Combination_Versus.setStyleSheet( "background-color: rgb(170, 170, 127);") self.QWebEngineview_Combination_Versus.setObjectName( "QWebEngineview_Combination_Versus") self.verticalLayout_8.addWidget(self.QWebEngineview_Combination_Versus) self.QWebEngineview_Combination_monte_markovitz.raise_() self.QWebEngineview_Combination_Versus.raise_() self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3) self.horizontalLayout_6.addWidget(self.scrollArea_3) self.tabWidget_PGMS.addTab(self.tab_Combination, "") self.verticalLayout_5.addWidget(self.tabWidget_PGMS) MainWindow.setCentralWidget(self.centralWidget) self.menuBar = QtWidgets.QMenuBar(MainWindow) self.menuBar.setGeometry(QtCore.QRect(0, 0, 913, 23)) self.menuBar.setObjectName("menuBar") MainWindow.setMenuBar(self.menuBar) self.action = QtWidgets.QAction(MainWindow) self.action.setObjectName("action") self.action_2 = QtWidgets.QAction(MainWindow) self.action_2.setObjectName("action_2") self.action_3 = QtWidgets.QAction(MainWindow) self.action_3.setObjectName("action_3") self.action_4 = QtWidgets.QAction(MainWindow) self.action_4.setObjectName("action_4") self.action_5 = QtWidgets.QAction(MainWindow) self.action_5.setObjectName("action_5") self.action_6 = QtWidgets.QAction(MainWindow) self.action_6.setObjectName("action_6") self.action_8 = QtWidgets.QAction(MainWindow) self.action_8.setObjectName("action_8") self.action_9 = QtWidgets.QAction(MainWindow) self.action_9.setObjectName("action_9") self.action_10 = QtWidgets.QAction(MainWindow) self.action_10.setObjectName("action_10") self.action_11 = QtWidgets.QAction(MainWindow) self.action_11.setObjectName("action_11") self.action_Qt = QtWidgets.QAction(MainWindow) self.action_Qt.setObjectName("action_Qt") self.action_PyQt = QtWidgets.QAction(MainWindow) self.action_PyQt.setObjectName("action_PyQt") self.action_12 = QtWidgets.QAction(MainWindow) self.action_12.setObjectName("action_12") self.retranslateUi(MainWindow) self.tabWidget_PGMS.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "基金量化投研系統v0.11")) self.label_10.setText(_translate("MainWindow", "收益")) self.label_11.setText(_translate("MainWindow", "最大回撤")) self.label_12.setText(_translate("MainWindow", "Sharp比")) self.label_8.setText(_translate("MainWindow", "最小範圍")) self.label_9.setText(_translate("MainWindow", "最大範圍")) self.pushButton_start_combination.setText( _translate("MainWindow", "開始")) self.checkBox_stock.setText(_translate("MainWindow", "股票策略")) self.checkBox_compound.setText(_translate("MainWindow", "複合策略")) self.checkBox_future_manage.setText(_translate("MainWindow", "管理期貨")) self.checkBox_event.setText(_translate("MainWindow", "事件驅動")) self.checkBox_bond.setText(_translate("MainWindow", "債券策略")) self.checkBox_macro.setText(_translate("MainWindow", "宏觀策略")) self.checkBox_combination_fund.setText(_translate( "MainWindow", "組合基金")) self.checkBox_relative_fund.setText(_translate("MainWindow", "相對價值")) self.checkBox_others.setText(_translate("MainWindow", "其他策略")) self.tabWidget_PGMS.setTabText( self.tabWidget_PGMS.indexOf(self.tab_Combination), _translate("MainWindow", "產品組合管理")) self.action.setText(_translate("MainWindow", "開啟")) self.action_2.setText(_translate("MainWindow", "關閉")) self.action_3.setText(_translate("MainWindow", "儲存")) self.action_4.setText(_translate("MainWindow", "退出")) self.action_5.setText(_translate("MainWindow", "複製")) self.action_6.setText(_translate("MainWindow", "貼上")) self.action_8.setText(_translate("MainWindow", "哈哈")) self.action_9.setText(_translate("MainWindow", "關於")) self.action_10.setText(_translate("MainWindow", "使用說明")) self.action_11.setText(_translate("MainWindow", "關於軟體")) self.action_Qt.setText(_translate("MainWindow", "關於Qt")) self.action_PyQt.setText(_translate("MainWindow", "關於PyQt")) self.action_12.setText(_translate("MainWindow", "其他"))
class Ui_FieldSelector(object): def setupUi(self, FieldSelector): FieldSelector.setObjectName("FieldSelector") FieldSelector.resize(964, 923) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/images/images/selector.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) FieldSelector.setWindowIcon(icon) FieldSelector.setSizeGripEnabled(True) FieldSelector.setModal(True) self.gridLayout_2 = QtWidgets.QGridLayout(FieldSelector) self.gridLayout_2.setObjectName("gridLayout_2") self.webView = QWebView(FieldSelector) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.webView.sizePolicy().hasHeightForWidth()) self.webView.setSizePolicy(sizePolicy) self.webView.setMouseTracking(True) self.webView.setUrl(QtCore.QUrl("about:blank")) self.webView.setObjectName("webView") self.gridLayout_2.addWidget(self.webView, 1, 0, 1, 2) self.textualFrame = QtWidgets.QFrame(FieldSelector) self.textualFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.textualFrame.setFrameShadow(QtWidgets.QFrame.Raised) self.textualFrame.setObjectName("textualFrame") self.gridLayout_5 = QtWidgets.QGridLayout(self.textualFrame) self.gridLayout_5.setObjectName("gridLayout_5") self.label_4 = QtWidgets.QLabel(self.textualFrame) self.label_4.setFrameShape(QtWidgets.QFrame.NoFrame) self.label_4.setFrameShadow(QtWidgets.QFrame.Plain) self.label_4.setLineWidth(0) self.label_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_4.setObjectName("label_4") self.gridLayout_5.addWidget(self.label_4, 0, 0, 1, 1) self.textualComboBox = QtWidgets.QComboBox(self.textualFrame) self.textualComboBox.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.textualComboBox.sizePolicy().hasHeightForWidth()) self.textualComboBox.setSizePolicy(sizePolicy) self.textualComboBox.setEditable(False) self.textualComboBox.setDuplicatesEnabled(False) self.textualComboBox.setObjectName("textualComboBox") self.gridLayout_5.addWidget(self.textualComboBox, 0, 1, 1, 1) self.label_3 = QtWidgets.QLabel(self.textualFrame) self.label_3.setFrameShape(QtWidgets.QFrame.NoFrame) self.label_3.setFrameShadow(QtWidgets.QFrame.Raised) self.label_3.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_3.setObjectName("label_3") self.gridLayout_5.addWidget(self.label_3, 1, 0, 1, 1) self.textcolComboBox = QtWidgets.QComboBox(self.textualFrame) self.textcolComboBox.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.textcolComboBox.sizePolicy().hasHeightForWidth()) self.textcolComboBox.setSizePolicy(sizePolicy) self.textcolComboBox.setEditable(True) self.textcolComboBox.setObjectName("textcolComboBox") self.gridLayout_5.addWidget(self.textcolComboBox, 1, 1, 1, 1) self.gridLayout_2.addWidget(self.textualFrame, 4, 0, 1, 1) self.url = QtWidgets.QLineEdit(FieldSelector) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.url.sizePolicy().hasHeightForWidth()) self.url.setSizePolicy(sizePolicy) self.url.setReadOnly(True) self.url.setObjectName("url") self.gridLayout_2.addWidget(self.url, 0, 0, 1, 2) self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.tagCheckBox = QtWidgets.QCheckBox(FieldSelector) self.tagCheckBox.setEnabled(False) font = QtGui.QFont() font.setPointSize(9) self.tagCheckBox.setFont(font) self.tagCheckBox.setChecked(True) self.tagCheckBox.setObjectName("tagCheckBox") self.gridLayout.addWidget(self.tagCheckBox, 4, 1, 1, 1) self.idCheckBox = QtWidgets.QCheckBox(FieldSelector) self.idCheckBox.setEnabled(False) font = QtGui.QFont() font.setPointSize(9) self.idCheckBox.setFont(font) self.idCheckBox.setChecked(True) self.idCheckBox.setObjectName("idCheckBox") self.gridLayout.addWidget(self.idCheckBox, 4, 2, 1, 1) self.classCheckBox = QtWidgets.QCheckBox(FieldSelector) self.classCheckBox.setEnabled(False) font = QtGui.QFont() font.setPointSize(9) self.classCheckBox.setFont(font) self.classCheckBox.setChecked(True) self.classCheckBox.setObjectName("classCheckBox") self.gridLayout.addWidget(self.classCheckBox, 4, 3, 1, 1) self.numElecomboBox = QtWidgets.QComboBox(FieldSelector) self.numElecomboBox.setEnabled(False) self.numElecomboBox.setObjectName("numElecomboBox") self.numElecomboBox.addItem("") self.gridLayout.addWidget(self.numElecomboBox, 4, 5, 1, 1) self.backButton = QtWidgets.QPushButton(FieldSelector) self.backButton.setMaximumSize(QtCore.QSize(100, 16777215)) self.backButton.setAutoDefault(False) self.backButton.setDefault(False) self.backButton.setObjectName("backButton") self.gridLayout.addWidget(self.backButton, 4, 6, 1, 1) self.nextButton = QtWidgets.QPushButton(FieldSelector) self.nextButton.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.nextButton.sizePolicy().hasHeightForWidth()) self.nextButton.setSizePolicy(sizePolicy) self.nextButton.setMaximumSize(QtCore.QSize(100, 16777215)) self.nextButton.setFocusPolicy(QtCore.Qt.StrongFocus) self.nextButton.setCheckable(False) self.nextButton.setChecked(False) self.nextButton.setAutoDefault(False) self.nextButton.setFlat(False) self.nextButton.setObjectName("nextButton") self.gridLayout.addWidget(self.nextButton, 4, 7, 1, 1) self.additionTagLineEdit = QtWidgets.QLineEdit(FieldSelector) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.additionTagLineEdit.sizePolicy().hasHeightForWidth()) self.additionTagLineEdit.setSizePolicy(sizePolicy) self.additionTagLineEdit.setObjectName("additionTagLineEdit") self.gridLayout.addWidget(self.additionTagLineEdit, 4, 4, 1, 1) self.gridLayout_2.addLayout(self.gridLayout, 2, 0, 1, 2) self.sourceText = QtWidgets.QPlainTextEdit(FieldSelector) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.sourceText.sizePolicy().hasHeightForWidth()) self.sourceText.setSizePolicy(sizePolicy) self.sourceText.setObjectName("sourceText") self.gridLayout_2.addWidget(self.sourceText, 3, 0, 1, 2) self.gridLayout_3 = QtWidgets.QGridLayout() self.gridLayout_3.setObjectName("gridLayout_3") self.state = QtWidgets.QLabel(FieldSelector) self.state.setText("") self.state.setObjectName("state") self.gridLayout_3.addWidget(self.state, 0, 0, 1, 1) self.warnLabel = QtWidgets.QLabel(FieldSelector) self.warnLabel.setMinimumSize(QtCore.QSize(0, 20)) self.warnLabel.setText("") self.warnLabel.setObjectName("warnLabel") self.gridLayout_3.addWidget(self.warnLabel, 1, 0, 1, 1) self.progressBar = QtWidgets.QProgressBar(FieldSelector) self.progressBar.setMaximumSize(QtCore.QSize(16777215, 30)) font = QtGui.QFont() font.setPointSize(11) self.progressBar.setFont(font) self.progressBar.setProperty("value", 0) self.progressBar.setObjectName("progressBar") self.gridLayout_3.addWidget(self.progressBar, 2, 0, 1, 1) self.gridLayout_2.addLayout(self.gridLayout_3, 5, 0, 1, 2) self.extractFrame = QtWidgets.QFrame(FieldSelector) self.extractFrame.setEnabled(False) self.extractFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.extractFrame.setFrameShadow(QtWidgets.QFrame.Raised) self.extractFrame.setObjectName("extractFrame") self.gridLayout_7 = QtWidgets.QGridLayout(self.extractFrame) self.gridLayout_7.setObjectName("gridLayout_7") self.widget = QtWidgets.QWidget(self.extractFrame) self.widget.setObjectName("widget") self.gridLayout_4 = QtWidgets.QGridLayout(self.widget) self.gridLayout_4.setObjectName("gridLayout_4") self.textExtraction = QtWidgets.QRadioButton(self.widget) self.textExtraction.setEnabled(False) self.textExtraction.setChecked(True) self.textExtraction.setObjectName("textExtraction") self.gridLayout_4.addWidget(self.textExtraction, 0, 0, 1, 1) self.sourceExtraction = QtWidgets.QRadioButton(self.widget) self.sourceExtraction.setObjectName("sourceExtraction") self.gridLayout_4.addWidget(self.sourceExtraction, 1, 0, 1, 1) self.gridLayout_7.addWidget(self.widget, 0, 0, 1, 1) self.widget_2 = QtWidgets.QWidget(self.extractFrame) self.widget_2.setObjectName("widget_2") self.gridLayout_6 = QtWidgets.QGridLayout(self.widget_2) self.gridLayout_6.setObjectName("gridLayout_6") self.selectedExtraction = QtWidgets.QRadioButton(self.widget_2) self.selectedExtraction.setChecked(True) self.selectedExtraction.setObjectName("selectedExtraction") self.gridLayout_6.addWidget(self.selectedExtraction, 0, 0, 1, 1) self.inverseExtraction = QtWidgets.QRadioButton(self.widget_2) self.inverseExtraction.setObjectName("inverseExtraction") self.gridLayout_6.addWidget(self.inverseExtraction, 1, 0, 1, 1) self.gridLayout_7.addWidget(self.widget_2, 0, 1, 1, 1) self.newcolumnButton = QtWidgets.QPushButton(self.extractFrame) self.newcolumnButton.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.newcolumnButton.sizePolicy().hasHeightForWidth()) self.newcolumnButton.setSizePolicy(sizePolicy) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(":/images/images/newColumn.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.newcolumnButton.setIcon(icon1) self.newcolumnButton.setIconSize(QtCore.QSize(36, 36)) self.newcolumnButton.setAutoDefault(True) self.newcolumnButton.setFlat(False) self.newcolumnButton.setObjectName("newcolumnButton") self.gridLayout_7.addWidget(self.newcolumnButton, 0, 2, 1, 1) self.gridLayout_2.addWidget(self.extractFrame, 4, 1, 1, 1) self.sourceText.raise_() self.textualFrame.raise_() self.url.raise_() self.webView.raise_() self.extractFrame.raise_() self.label_4.setBuddy(self.textualComboBox) self.label_3.setBuddy(self.textcolComboBox) self.retranslateUi(FieldSelector) QtCore.QMetaObject.connectSlotsByName(FieldSelector) def retranslateUi(self, FieldSelector): _translate = QtCore.QCoreApplication.translate FieldSelector.setWindowTitle( _translate("FieldSelector", "Gromoteur - Field Selector")) self.webView.setStatusTip( _translate( "FieldSelector", "click to select desired content, scroll with mouse wheel")) self.label_4.setText( _translate("FieldSelector", "Te&xtualization Name:")) self.label_3.setText(_translate("FieldSelector", "Column &Name:")) self.tagCheckBox.setText(_translate("FieldSelector", "tag")) self.idCheckBox.setText(_translate("FieldSelector", "id")) self.classCheckBox.setText(_translate("FieldSelector", "class")) self.numElecomboBox.setItemText(0, _translate("FieldSelector", "all")) self.backButton.setText(_translate("FieldSelector", "previous")) self.nextButton.setText(_translate("FieldSelector", "next")) self.additionTagLineEdit.setToolTip( _translate("FieldSelector", "additional tag")) self.textExtraction.setText(_translate("FieldSelector", "text")) self.sourceExtraction.setText(_translate("FieldSelector", "source")) self.selectedExtraction.setText( _translate("FieldSelector", "se&lected")) self.inverseExtraction.setText(_translate("FieldSelector", "in&verse")) self.newcolumnButton.setText( _translate("FieldSelector", "extract\n" "into separate column"))
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setEnabled(True) MainWindow.resize(913, 971) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(3) sizePolicy.setVerticalStretch(33) sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) MainWindow.setSizePolicy(sizePolicy) MainWindow.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) MainWindow.setAutoFillBackground(True) MainWindow.setStyleSheet("") MainWindow.setAnimated(True) self.centralWidget = QtWidgets.QWidget(MainWindow) self.centralWidget.setObjectName("centralWidget") self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.centralWidget) self.verticalLayout_5.setObjectName("verticalLayout_5") self.tabWidget_PGMS = QtWidgets.QTabWidget(self.centralWidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(20) sizePolicy.setVerticalStretch(44) sizePolicy.setHeightForWidth(self.tabWidget_PGMS.sizePolicy().hasHeightForWidth()) self.tabWidget_PGMS.setSizePolicy(sizePolicy) self.tabWidget_PGMS.setMinimumSize(QtCore.QSize(800, 700)) self.tabWidget_PGMS.setLayoutDirection(QtCore.Qt.LeftToRight) self.tabWidget_PGMS.setAutoFillBackground(True) self.tabWidget_PGMS.setStyleSheet("") self.tabWidget_PGMS.setTabBarAutoHide(True) self.tabWidget_PGMS.setObjectName("tabWidget_PGMS") self.tab_Combination = QtWidgets.QWidget() self.tab_Combination.setObjectName("tab_Combination") self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.tab_Combination) self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.scrollArea_3 = QtWidgets.QScrollArea(self.tab_Combination) self.scrollArea_3.setWidgetResizable(True) self.scrollArea_3.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.scrollArea_3.setObjectName("scrollArea_3") self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 852, 958)) self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_3) self.verticalLayout_8.setContentsMargins(0, 0, 0, 0) self.verticalLayout_8.setObjectName("verticalLayout_8") self.verticalLayout_6 = QtWidgets.QVBoxLayout() self.verticalLayout_6.setObjectName("verticalLayout_6") self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setObjectName("horizontalLayout_3") spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem) self.verticalLayout_7 = QtWidgets.QVBoxLayout() self.verticalLayout_7.setObjectName("verticalLayout_7") self.label_7 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_7.setText("") self.label_7.setObjectName("label_7") self.verticalLayout_7.addWidget(self.label_7) self.label_10 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_10.sizePolicy().hasHeightForWidth()) self.label_10.setSizePolicy(sizePolicy) self.label_10.setObjectName("label_10") self.verticalLayout_7.addWidget(self.label_10) self.label_11 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_11.setObjectName("label_11") self.verticalLayout_7.addWidget(self.label_11) self.label_12 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_12.setObjectName("label_12") self.verticalLayout_7.addWidget(self.label_12) self.horizontalLayout_3.addLayout(self.verticalLayout_7) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.horizontalLayout_3.addItem(spacerItem1) self.gridLayout_5 = QtWidgets.QGridLayout() self.gridLayout_5.setObjectName("gridLayout_5") self.label_8 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_8.setObjectName("label_8") self.gridLayout_5.addWidget(self.label_8, 0, 0, 1, 1) self.label_9 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_9.setObjectName("label_9") self.gridLayout_5.addWidget(self.label_9, 0, 1, 1, 1) self.doubleSpinBox_returns_min = QtWidgets.QDoubleSpinBox(self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.doubleSpinBox_returns_min.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_returns_min.setSizePolicy(sizePolicy) self.doubleSpinBox_returns_min.setMaximum(0.3) self.doubleSpinBox_returns_min.setSingleStep(0.01) self.doubleSpinBox_returns_min.setProperty("value", 0.0) self.doubleSpinBox_returns_min.setObjectName("doubleSpinBox_returns_min") self.gridLayout_5.addWidget(self.doubleSpinBox_returns_min, 1, 0, 1, 1) self.doubleSpinBox_returns_max = QtWidgets.QDoubleSpinBox(self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.doubleSpinBox_returns_max.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_returns_max.setSizePolicy(sizePolicy) self.doubleSpinBox_returns_max.setMinimum(0.0) self.doubleSpinBox_returns_max.setMaximum(10.0) self.doubleSpinBox_returns_max.setSingleStep(0.1) self.doubleSpinBox_returns_max.setProperty("value", 0.0) self.doubleSpinBox_returns_max.setObjectName("doubleSpinBox_returns_max") self.gridLayout_5.addWidget(self.doubleSpinBox_returns_max, 1, 1, 1, 1) self.doubleSpinBox_maxdrawdown_min = QtWidgets.QDoubleSpinBox(self.scrollAreaWidgetContents_3) self.doubleSpinBox_maxdrawdown_min.setMinimum(0.1) self.doubleSpinBox_maxdrawdown_min.setMaximum(1.0) self.doubleSpinBox_maxdrawdown_min.setSingleStep(0.01) self.doubleSpinBox_maxdrawdown_min.setProperty("value", 0.7) self.doubleSpinBox_maxdrawdown_min.setObjectName("doubleSpinBox_maxdrawdown_min") self.gridLayout_5.addWidget(self.doubleSpinBox_maxdrawdown_min, 2, 0, 1, 1) self.doubleSpinBox_maxdrawdown_max = QtWidgets.QDoubleSpinBox(self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.doubleSpinBox_maxdrawdown_max.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_maxdrawdown_max.setSizePolicy(sizePolicy) self.doubleSpinBox_maxdrawdown_max.setMinimum(0.2) self.doubleSpinBox_maxdrawdown_max.setMaximum(1.0) self.doubleSpinBox_maxdrawdown_max.setSingleStep(0.01) self.doubleSpinBox_maxdrawdown_max.setProperty("value", 1.0) self.doubleSpinBox_maxdrawdown_max.setObjectName("doubleSpinBox_maxdrawdown_max") self.gridLayout_5.addWidget(self.doubleSpinBox_maxdrawdown_max, 2, 1, 1, 1) self.doubleSpinBox_sharp_min = QtWidgets.QDoubleSpinBox(self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.doubleSpinBox_sharp_min.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_sharp_min.setSizePolicy(sizePolicy) self.doubleSpinBox_sharp_min.setMaximum(40.0) self.doubleSpinBox_sharp_min.setSingleStep(0.05) self.doubleSpinBox_sharp_min.setObjectName("doubleSpinBox_sharp_min") self.gridLayout_5.addWidget(self.doubleSpinBox_sharp_min, 3, 0, 1, 1) self.doubleSpinBox_sharp_max = QtWidgets.QDoubleSpinBox(self.scrollAreaWidgetContents_3) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.doubleSpinBox_sharp_max.sizePolicy().hasHeightForWidth()) self.doubleSpinBox_sharp_max.setSizePolicy(sizePolicy) self.doubleSpinBox_sharp_max.setProperty("value", 10.0) self.doubleSpinBox_sharp_max.setObjectName("doubleSpinBox_sharp_max") self.gridLayout_5.addWidget(self.doubleSpinBox_sharp_max, 3, 1, 1, 1) self.horizontalLayout_3.addLayout(self.gridLayout_5) self.line_2 = QtWidgets.QFrame(self.scrollAreaWidgetContents_3) self.line_2.setFrameShape(QtWidgets.QFrame.VLine) self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_2.setObjectName("line_2") self.horizontalLayout_3.addWidget(self.line_2) spacerItem2 = QtWidgets.QSpacerItem(200, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem2) self.pushButton_start_combination = QtWidgets.QPushButton(self.scrollAreaWidgetContents_3) self.pushButton_start_combination.setObjectName("pushButton_start_combination") self.horizontalLayout_3.addWidget(self.pushButton_start_combination) spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem3) self.verticalLayout_6.addLayout(self.horizontalLayout_3) self.horizontalLayout_7 = QtWidgets.QHBoxLayout() self.horizontalLayout_7.setObjectName("horizontalLayout_7") self.checkBox_stock = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_stock.setObjectName("checkBox_stock") self.horizontalLayout_7.addWidget(self.checkBox_stock) self.checkBox_compound = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_compound.setObjectName("checkBox_compound") self.horizontalLayout_7.addWidget(self.checkBox_compound) self.checkBox_future_manage = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_future_manage.setObjectName("checkBox_future_manage") self.horizontalLayout_7.addWidget(self.checkBox_future_manage) self.checkBox_event = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_event.setObjectName("checkBox_event") self.horizontalLayout_7.addWidget(self.checkBox_event) self.checkBox_bond = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_bond.setObjectName("checkBox_bond") self.horizontalLayout_7.addWidget(self.checkBox_bond) self.checkBox_macro = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_macro.setObjectName("checkBox_macro") self.horizontalLayout_7.addWidget(self.checkBox_macro) self.checkBox_combination_fund = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_combination_fund.setObjectName("checkBox_combination_fund") self.horizontalLayout_7.addWidget(self.checkBox_combination_fund) self.checkBox_relative_fund = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_relative_fund.setObjectName("checkBox_relative_fund") self.horizontalLayout_7.addWidget(self.checkBox_relative_fund) self.checkBox_others = QtWidgets.QCheckBox(self.scrollAreaWidgetContents_3) self.checkBox_others.setObjectName("checkBox_others") self.horizontalLayout_7.addWidget(self.checkBox_others) self.verticalLayout_6.addLayout(self.horizontalLayout_7) self.verticalLayout_8.addLayout(self.verticalLayout_6) self.QWebEngineview_Combination_monte_markovitz = QWebEngineView(self.scrollAreaWidgetContents_3) self.QWebEngineview_Combination_monte_markovitz.setMinimumSize(QtCore.QSize(0, 300)) self.QWebEngineview_Combination_monte_markovitz.setStyleSheet("background-color: rgb(170, 170, 127);") self.QWebEngineview_Combination_monte_markovitz.setObjectName("QWebEngineview_Combination_monte_markovitz") self.verticalLayout_8.addWidget(self.QWebEngineview_Combination_monte_markovitz) self.horizontalLayout_5 = QtWidgets.QHBoxLayout() self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.QWebEngineview_Combination_Pie = QWebEngineView(self.scrollAreaWidgetContents_3) self.QWebEngineview_Combination_Pie.setMinimumSize(QtCore.QSize(50, 200)) self.QWebEngineview_Combination_Pie.setStyleSheet("background-color: rgb(170, 170, 127);") self.QWebEngineview_Combination_Pie.setObjectName("QWebEngineview_Combination_Pie") self.horizontalLayout_5.addWidget(self.QWebEngineview_Combination_Pie) self.QWebEngineview_Combination_Table = QWebEngineView(self.scrollAreaWidgetContents_3) self.QWebEngineview_Combination_Table.setMinimumSize(QtCore.QSize(0, 200)) self.QWebEngineview_Combination_Table.setStyleSheet("background-color: rgb(170, 170, 127);") self.QWebEngineview_Combination_Table.setObjectName("QWebEngineview_Combination_Table") self.horizontalLayout_5.addWidget(self.QWebEngineview_Combination_Table) self.verticalLayout_8.addLayout(self.horizontalLayout_5) self.QWebEngineview_Combination_Versus = QWebEngineView(self.scrollAreaWidgetContents_3) self.QWebEngineview_Combination_Versus.setEnabled(True) self.QWebEngineview_Combination_Versus.setMinimumSize(QtCore.QSize(0, 300)) self.QWebEngineview_Combination_Versus.setStyleSheet("background-color: rgb(170, 170, 127);") self.QWebEngineview_Combination_Versus.setObjectName("QWebEngineview_Combination_Versus") self.verticalLayout_8.addWidget(self.QWebEngineview_Combination_Versus) self.QWebEngineview_Combination_monte_markovitz.raise_() self.QWebEngineview_Combination_Versus.raise_() self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3) self.horizontalLayout_6.addWidget(self.scrollArea_3) self.tabWidget_PGMS.addTab(self.tab_Combination, "") self.verticalLayout_5.addWidget(self.tabWidget_PGMS) MainWindow.setCentralWidget(self.centralWidget) self.menuBar = QtWidgets.QMenuBar(MainWindow) self.menuBar.setGeometry(QtCore.QRect(0, 0, 913, 23)) self.menuBar.setObjectName("menuBar") MainWindow.setMenuBar(self.menuBar) self.action = QtWidgets.QAction(MainWindow) self.action.setObjectName("action") self.action_2 = QtWidgets.QAction(MainWindow) self.action_2.setObjectName("action_2") self.action_3 = QtWidgets.QAction(MainWindow) self.action_3.setObjectName("action_3") self.action_4 = QtWidgets.QAction(MainWindow) self.action_4.setObjectName("action_4") self.action_5 = QtWidgets.QAction(MainWindow) self.action_5.setObjectName("action_5") self.action_6 = QtWidgets.QAction(MainWindow) self.action_6.setObjectName("action_6") self.action_8 = QtWidgets.QAction(MainWindow) self.action_8.setObjectName("action_8") self.action_9 = QtWidgets.QAction(MainWindow) self.action_9.setObjectName("action_9") self.action_10 = QtWidgets.QAction(MainWindow) self.action_10.setObjectName("action_10") self.action_11 = QtWidgets.QAction(MainWindow) self.action_11.setObjectName("action_11") self.action_Qt = QtWidgets.QAction(MainWindow) self.action_Qt.setObjectName("action_Qt") self.action_PyQt = QtWidgets.QAction(MainWindow) self.action_PyQt.setObjectName("action_PyQt") self.action_12 = QtWidgets.QAction(MainWindow) self.action_12.setObjectName("action_12") self.retranslateUi(MainWindow) self.tabWidget_PGMS.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "基金量化投研系统v0.11")) self.label_10.setText(_translate("MainWindow", "收益")) self.label_11.setText(_translate("MainWindow", "最大回撤")) self.label_12.setText(_translate("MainWindow", "Sharp比")) self.label_8.setText(_translate("MainWindow", "最小范围")) self.label_9.setText(_translate("MainWindow", "最大范围")) self.pushButton_start_combination.setText(_translate("MainWindow", "开始")) self.checkBox_stock.setText(_translate("MainWindow", "股票策略")) self.checkBox_compound.setText(_translate("MainWindow", "复合策略")) self.checkBox_future_manage.setText(_translate("MainWindow", "管理期货")) self.checkBox_event.setText(_translate("MainWindow", "事件驱动")) self.checkBox_bond.setText(_translate("MainWindow", "债券策略")) self.checkBox_macro.setText(_translate("MainWindow", "宏观策略")) self.checkBox_combination_fund.setText(_translate("MainWindow", "组合基金")) self.checkBox_relative_fund.setText(_translate("MainWindow", "相对价值")) self.checkBox_others.setText(_translate("MainWindow", "其它策略")) self.tabWidget_PGMS.setTabText(self.tabWidget_PGMS.indexOf(self.tab_Combination), _translate("MainWindow", "产品组合管理")) self.action.setText(_translate("MainWindow", "打开")) self.action_2.setText(_translate("MainWindow", "关闭")) self.action_3.setText(_translate("MainWindow", "保存")) self.action_4.setText(_translate("MainWindow", "退出")) self.action_5.setText(_translate("MainWindow", "复制")) self.action_6.setText(_translate("MainWindow", "黏贴")) self.action_8.setText(_translate("MainWindow", "哈哈")) self.action_9.setText(_translate("MainWindow", "关于")) self.action_10.setText(_translate("MainWindow", "使用说明")) self.action_11.setText(_translate("MainWindow", "关于软件")) self.action_Qt.setText(_translate("MainWindow", "关于Qt")) self.action_PyQt.setText(_translate("MainWindow", "关于PyQt")) self.action_12.setText(_translate("MainWindow", "其他"))
class TopActor(object): def setupUi(self, dialog): dialog.setObjectName("dialog") dialog.resize(755, 793) self.closeWinBtn = QtWidgets.QPushButton(dialog) self.closeWinBtn.setGeometry(QtCore.QRect(580, 730, 131, 31)) self.closeWinBtn.setObjectName("closeWinBtn") self.label_picture = QtWidgets.QLabel(dialog) self.label_picture.setGeometry(QtCore.QRect(-180, 0, 1150, 850)) self.label_picture.setStyleSheet("image: url(:/new/back_actor.jpg);") self.label_picture.setText("") self.label_picture.setObjectName("label_picture") self.pushButton = QtWidgets.QPushButton(dialog) self.pushButton.setGeometry(QtCore.QRect(410, 120, 93, 28)) self.pushButton.setObjectName("pushButton") self.label_result = QWebEngineView(self) self.label_result.setGeometry(QtCore.QRect(50, 200, 640, 480)) #self.label_result.setText("") self.label_result.setObjectName("label_result") self.AddTo = QtWidgets.QPushButton(dialog) self.AddTo.setGeometry(QtCore.QRect(310, 730, 121, 28)) self.AddTo.setObjectName("AddTo") self.label = QtWidgets.QLabel(dialog) self.label.setGeometry(QtCore.QRect(50, 120, 41, 31)) font = QtGui.QFont() font.setFamily("Agency FB") font.setPointSize(12) self.label.setFont(font) self.label.setObjectName("label") self.spinBox = QtWidgets.QSpinBox(dialog) self.spinBox.setGeometry(QtCore.QRect(100, 125, 61, 22)) self.spinBox.setMinimum(2015) self.spinBox.setMaximum(2020) self.spinBox.setObjectName("spinBox") self.spinBox_2 = QtWidgets.QSpinBox(dialog) self.spinBox_2.setGeometry(QtCore.QRect(255, 125, 46, 22)) self.spinBox_2.setMinimum(1) self.spinBox_2.setMaximum(20) self.spinBox_2.setObjectName("spinBox_2") self.label_2 = QtWidgets.QLabel(dialog) self.label_2.setGeometry(QtCore.QRect(210, 120, 41, 31)) font = QtGui.QFont() font.setFamily("Agency FB") font.setPointSize(12) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.label_picture.raise_() self.closeWinBtn.raise_() self.pushButton.raise_() self.label_result.raise_() self.AddTo.raise_() self.label.raise_() self.spinBox.raise_() self.spinBox_2.raise_() self.label_2.raise_() self.retranslateUi(dialog) self.closeWinBtn.clicked.connect(dialog.close) QtCore.QMetaObject.connectSlotsByName(dialog) self.pushButton.clicked.connect(self.on_click) self.AddTo.clicked.connect(self.put_into_report) def retranslateUi(self, dialog): _translate = QtCore.QCoreApplication.translate dialog.setWindowTitle(_translate("dialog", "劳模演员")) self.closeWinBtn.setText(_translate("dialog", "返回上一级")) self.pushButton.setText(_translate("dialog", "生成图表")) self.AddTo.setText(_translate("dialog", "加入到数据报表")) self.label.setText(_translate("dialog", "年份")) self.label_2.setText(_translate("dialog", "排名")) def on_click(self, dialog): Actor(self.spinBox.value(), self.spinBox_2.value()) #pixMap = QPixmap("Top_actor.jpg").scaled(self.label_result.width(),self.label_result.height()) #self.label_result.setPixmap(QPixmap("")) #self.label_result.setPixmap(pixMap) pwd = os.getcwd() url_string = os.path.abspath('./SE12_Cache/Actor.html') self.label_result.load(QUrl.fromLocalFile(url_string)) def cut_image(self, dialog): size = self.label_result.size() img = QtGui.QImage(size, QtGui.QImage.Format_ARGB32) painter = QtGui.QPainter(img) self.label_result.render(painter) self.label_result.render(painter) img.save('./SE12_Cache/Top_actor.png') painter.end() def put_into_report(self, dialog): try: doc = Document('report.docx') except Exception: #不存在文件则新建 self.cut_image(dialog) doc = Document() doc.save('report.docx') doc = Document('report.docx') #插入图片 images = './SE12_Cache/Top_actor.png' # 要插入的图片 doc.add_paragraph('\n') # 添加文字 doc.add_picture(images, width=Inches(6)) # 添加图, 设置宽度 doc.save('report.docx') # 保存路径 print('Add picture to report Succesfully.') else: self.cut_image(dialog) images = './SE12_Cache/Top_actor.png' doc.add_paragraph('\n') doc.add_picture(images, width=Inches(6)) doc.save('report.docx') print('Add picture to report Succesfully.')
class Line(object): def setupUi(self, dialog): dialog.setObjectName("dialog") dialog.resize(742, 750) #dialog.resize(1742, 1750) self.closeWinBtn = QtWidgets.QPushButton(dialog) self.closeWinBtn.setGeometry(QtCore.QRect(580, 690, 131, 31)) self.closeWinBtn.setObjectName("closeWinBtn") self.label_picture = QtWidgets.QLabel(dialog) self.label_picture.setGeometry(QtCore.QRect(-200, 0, 1150, 850)) self.label_picture.setStyleSheet("image: url(:/new/back_line.jpg);") self.label_picture.setText("") self.label_picture.setObjectName("label_picture") self.spinBox_year = QtWidgets.QSpinBox(dialog) self.spinBox_year.setGeometry(QtCore.QRect(110, 120, 61, 22)) self.spinBox_year.setMinimum(2015) self.spinBox_year.setMaximum(2020) self.spinBox_year.setObjectName("spinBox_year") self.label_texts = QtWidgets.QLabel(dialog) self.label_texts.setGeometry(QtCore.QRect(60, 120, 41, 21)) font = QtGui.QFont() font.setFamily("Agency FB") font.setPointSize(12) self.label_texts.setFont(font) self.label_texts.setObjectName("label_texts") self.pushButton = QtWidgets.QPushButton(dialog) self.pushButton.setGeometry(QtCore.QRect(460, 120, 93, 28)) self.pushButton.setObjectName("pushButton") self.AddTo = QtWidgets.QPushButton(dialog) self.AddTo.setGeometry(QtCore.QRect(290, 690, 121, 28)) self.AddTo.setObjectName("AddTo") self.spinBox_year_2 = QtWidgets.QSpinBox(dialog) self.spinBox_year_2.setGeometry(QtCore.QRect(230, 120, 61, 22)) self.spinBox_year_2.setMinimum(2015) self.spinBox_year_2.setMaximum(2020) self.spinBox_year_2.setObjectName("spinBox_year_2") self.spinBox_year_3 = QtWidgets.QSpinBox(dialog) self.spinBox_year_3.setGeometry(QtCore.QRect(355, 120, 61, 22)) self.spinBox_year_3.setMinimum(2015) self.spinBox_year_3.setMaximum(2020) self.spinBox_year_3.setObjectName("spinBox_year_3") self.label_texts_2 = QtWidgets.QLabel(dialog) self.label_texts_2.setGeometry(QtCore.QRect(190, 120, 41, 21)) font = QtGui.QFont() font.setFamily("Agency FB") font.setPointSize(12) self.label_texts_2.setFont(font) self.label_texts_2.setObjectName("label_texts_2") self.label_texts_3 = QtWidgets.QLabel(dialog) self.label_texts_3.setGeometry(QtCore.QRect(310, 120, 41, 21)) font = QtGui.QFont() font.setFamily("Agency FB") font.setPointSize(12) self.label_texts_3.setFont(font) self.label_texts_3.setObjectName("label_texts_3") #self.widget = QtWidgets.QWidget(dialog) self.label_result = QWebEngineView(self) self.label_result.setGeometry(QtCore.QRect(50, 180, 640, 480)) self.label_result.setObjectName("widget") self.label_picture.raise_() self.closeWinBtn.raise_() self.spinBox_year.raise_() self.label_texts.raise_() self.pushButton.raise_() self.AddTo.raise_() self.spinBox_year_2.raise_() self.spinBox_year_3.raise_() self.label_texts_2.raise_() self.label_texts_3.raise_() self.label_result.raise_() self.retranslateUi(dialog) self.closeWinBtn.clicked.connect(dialog.close) QtCore.QMetaObject.connectSlotsByName(dialog) self.pushButton.clicked.connect(self.on_click) self.AddTo.clicked.connect(self.put_into_report) def retranslateUi(self, dialog): _translate = QtCore.QCoreApplication.translate dialog.setWindowTitle(_translate("dialog", "Dialog")) self.closeWinBtn.setText(_translate("dialog", "返回上一级")) self.label_texts.setText(_translate("dialog", "年份")) self.pushButton.setText(_translate("dialog", "生成图表")) self.AddTo.setText(_translate("dialog", "加入到数据报表")) self.label_texts_2.setText(_translate("dialog", "年份")) self.label_texts_3.setText(_translate("dialog", "年份")) def on_click(self,dialog): line(self.spinBox_year.value(), self.spinBox_year_2.value(),self.spinBox_year_3.value()) pwd = os.getcwd() url_string=os.path.abspath('./SE12_Cache/Line.html') self.label_result.load(QUrl.fromLocalFile(url_string)) def cut_image(self, dialog): size = self.label_result.size() img = QtGui.QImage(size, QtGui.QImage.Format_ARGB32) painter = QtGui.QPainter(img) self.label_result.render(painter) self.label_result.render(painter) img.save('./SE12_Cache/Line.png') painter.end() def put_into_report(self,dialog): try: doc = Document('report.docx') except Exception: #不存在文件则新建 self.cut_image(dialog) doc = Document() doc.save('report.docx') doc = Document('report.docx') #插入图片 images = './SE12_Cache/Line.png' # 要插入的图片 doc.add_paragraph('\n') # 添加文字 doc.add_picture(images, width = Inches(6)) # 添加图, 设置宽度 doc.save('report.docx') # 保存路径 print('Add picture to report Succesfully.') else: self.cut_image(dialog) images = './SE12_Cache/Line.png' doc.add_paragraph('\n') doc.add_picture(images, width = Inches(6)) doc.save('report.docx') print('Add picture to report Succesfully.')
class Big(object): def setupUi(self, dialog): dialog.setObjectName("dialog") dialog.resize(1330, 850) self.closeWinBtn = QtWidgets.QPushButton(dialog) self.closeWinBtn.setGeometry(QtCore.QRect(1160, 780, 131, 31)) self.closeWinBtn.setObjectName("closeWinBtn") self.spinBox_season = QtWidgets.QSpinBox(dialog) self.spinBox_season.setGeometry(QtCore.QRect(640, 60, 46, 22)) self.spinBox_season.setMinimum(1) self.spinBox_season.setMaximum(4) self.spinBox_season.setObjectName("spinBox_season") self.label_picture = QtWidgets.QLabel(dialog) self.label_picture.setGeometry(QtCore.QRect(-50, -110, 1541, 1071)) self.label_picture.setStyleSheet("image: url(:/new/back_big.jpg);") self.label_picture.setText("") self.label_picture.setObjectName("label_picture") self.spinBox_year = QtWidgets.QSpinBox(dialog) self.spinBox_year.setGeometry(QtCore.QRect(530, 60, 61, 22)) self.spinBox_year.setMinimum(2015) self.spinBox_year.setMaximum(2020) self.spinBox_year.setObjectName("spinBox_year") self.label_texts = QtWidgets.QLabel(dialog) self.label_texts.setGeometry(QtCore.QRect(440, 60, 81, 21)) font = QtGui.QFont() font.setFamily("Agency FB") font.setPointSize(12) self.label_texts.setFont(font) self.label_texts.setObjectName("label_texts") self.pushButton = QtWidgets.QPushButton(dialog) self.pushButton.setGeometry(QtCore.QRect(780, 60, 93, 28)) self.pushButton.setObjectName("pushButton") self.label_result1 = QWebEngineView(self) self.label_result1.setGeometry(QtCore.QRect(10, 150, 640, 480)) #self.label_result1.setText("") self.label_result1.setObjectName("label_result1") self.AddTo = QtWidgets.QPushButton(dialog) self.AddTo.setGeometry(QtCore.QRect(260, 700, 121, 28)) self.AddTo.setObjectName("AddTo") self.label_result2 = QWebEngineView(self) self.label_result2.setGeometry(QtCore.QRect(680, 150, 640, 480)) #self.label_result2.setText("") self.label_result2.setObjectName("label_result2") self.AddTo_2 = QtWidgets.QPushButton(dialog) self.AddTo_2.setGeometry(QtCore.QRect(940, 700, 121, 28)) self.AddTo_2.setObjectName("AddTo_2") self.label_texts_2 = QtWidgets.QLabel(dialog) self.label_texts_2.setGeometry(QtCore.QRect(594, 60, 41, 21)) font = QtGui.QFont() font.setFamily("Agency FB") font.setPointSize(12) self.label_texts_2.setFont(font) self.label_texts_2.setObjectName("label_texts_2") self.label_texts_3 = QtWidgets.QLabel(dialog) self.label_texts_3.setGeometry(QtCore.QRect(690, 60, 81, 21)) font = QtGui.QFont() font.setFamily("Agency FB") font.setPointSize(12) self.label_texts_3.setFont(font) self.label_texts_3.setObjectName("label_texts_3") self.label_picture.raise_() self.closeWinBtn.raise_() self.spinBox_season.raise_() self.spinBox_year.raise_() self.label_texts.raise_() self.pushButton.raise_() self.label_result1.raise_() self.AddTo.raise_() self.label_result2.raise_() self.AddTo_2.raise_() self.label_texts_2.raise_() self.label_texts_3.raise_() self.retranslateUi(dialog) self.closeWinBtn.clicked.connect(dialog.close) QtCore.QMetaObject.connectSlotsByName(dialog) self.pushButton.clicked.connect(self.on_click) self.AddTo.clicked.connect(self.put_into_report1) self.AddTo_2.clicked.connect(self.put_into_report2) def retranslateUi(self, dialog): _translate = QtCore.QCoreApplication.translate dialog.setWindowTitle(_translate("dialog", "票房份额")) self.closeWinBtn.setText(_translate("dialog", "返回上一级")) self.label_texts.setText(_translate("dialog", "选择时间")) self.pushButton.setText(_translate("dialog", "生成图表")) self.AddTo.setText(_translate("dialog", "加入到数据报表")) self.AddTo_2.setText(_translate("dialog", "加入到数据报表")) self.label_texts_2.setText(_translate("dialog", "年第")) self.label_texts_3.setText(_translate("dialog", "季度")) def on_click(self, dialog): Straight(self.spinBox_year.value(), self.spinBox_season.value()) pie(self.spinBox_year.value(), self.spinBox_season.value()) pwd = os.getcwd() url_string1 = os.path.abspath('./SE12_Cache/Straight.html') self.label_result1.load(QUrl.fromLocalFile(url_string1)) url_string2 = os.path.abspath('./SE12_Cache/Pie.html') self.label_result2.load(QUrl.fromLocalFile(url_string2)) def cut_image1(self, dialog): size = self.label_result1.size() img = QtGui.QImage(size, QtGui.QImage.Format_ARGB32) painter = QtGui.QPainter(img) self.label_result1.render(painter) self.label_result1.render(painter) img.save('./SE12_Cache/Straight.png') painter.end() def cut_image2(self, dialog): size = self.label_result2.size() img = QtGui.QImage(size, QtGui.QImage.Format_ARGB32) painter = QtGui.QPainter(img) self.label_result2.render(painter) self.label_result2.render(painter) img.save('./SE12_Cache/Pie.png') painter.end() def put_into_report1(self, dialog): try: doc = Document('report.docx') except Exception: #不存在文件则新建 self.cut_image1(dialog) doc = Document() doc.save('report.docx') doc = Document('report.docx') #插入图片 images = './SE12_Cache/Straight.png' # 要插入的图片 doc.add_paragraph('\n') # 添加文字 doc.add_picture(images, width=Inches(6)) # 添加图, 设置宽度 doc.save('report.docx') # 保存路径 print('Add picture to report Succesfully.') else: self.cut_image1(dialog) images = './SE12_Cache/Straight.png' doc.add_paragraph('\n') doc.add_picture(images, width=Inches(6)) doc.save('report.docx') print('Add picture to report Succesfully.') def put_into_report2(self, dialog): try: doc = Document('report.docx') except Exception: #不存在文件则新建 self.cut_image2(dialog) doc = Document() doc.save('report.docx') doc = Document('report.docx') #插入图片 images = './SE12_Cache/Pie.png' # 要插入的图片 doc.add_paragraph('\n') # 添加文字 doc.add_picture(images, width=Inches(6)) # 添加图, 设置宽度 doc.save('report.docx') # 保存路径 print('Add picture to report Succesfully.') else: self.cut_image2(dialog) images = './SE12_Cache/Pie.png' doc.add_paragraph('\n') doc.add_picture(images, width=Inches(6)) doc.save('report.docx') print('Add picture to report Succesfully.')
class Page(QWebEnginePage): def __init__(self, view): super(Page, self).__init__() self.parent = view.parent self.view = view self.result = QVariant() self.fullView = QWebEngineView() self.exitFSAction = QAction(self.fullView) self.loop = None def javaScriptConsoleMessage(self, level, msg, line, sourceID): """Override javaScriptConsoleMessage to use debug log.""" if level == QWebEnginePage.InfoMessageLevel: print("JS - INFO - Ligne {} : {}".format(line, msg)) elif level == QWebEnginePage.WarningMessageLevel: print("JS - WARNING - Ligne {} : {}".format(line, msg)) else: print("JS - ERROR - Ligne {} : {}".format(line, msg)) def hittestcontent(self, pos): return WebHitTestResult(self, pos) def maptoviewport(self, pos): return QPointF(pos.x(), pos.y()) def executejavascript(self, scriptsrc): self.loop = QEventLoop() self.result = QVariant() QTimer.singleShot(250, self.loop.quit) self.runJavaScript(scriptsrc, self.callbackjs) self.loop.exec_() self.loop = None return self.result def callbackjs(self, res): if self.loop is not None and self.loop.isRunning(): self.result = res self.loop.quit() def vsource(self): if "view-source:http" in self.url().toString(): self.load(QUrl(self.url().toString().split("view-source:")[1])) else: self.triggerAction(self.ViewSource) def cutaction(self): self.triggerAction(self.Cut) def copyaction(self): self.triggerAction(self.Copy) def pasteaction(self): self.triggerAction(self.Paste) def exitfs(self): self.triggerAction(self.ExitFullScreen) def makefullscreen(self, request): if request.toggleOn(): self.fullView = QWebEngineView() self.exitFSAction = QAction(self.fullView) self.exitFSAction.setShortcut(Qt.Key_Escape) self.exitFSAction.triggered.connect(self.exitfs) self.fullView.addAction(self.exitFSAction) self.setView(self.fullView) self.fullView.showFullScreen() self.fullView.raise_() else: del self.fullView self.setView(self.view) request.accept()
class VisualizerGUI(QMainWindow): """ ILLIXR_Visualizer's View (GUI). Defines the main window. Displays plots and interfaces with user. """ # Define signals for signalling Controller loadSignal = QtCore.pyqtSignal() reorderSignal = QtCore.pyqtSignal() leftSignal = QtCore.pyqtSignal() rightSignal = QtCore.pyqtSignal() def __init__(self): """ View initializer. """ super().__init__() # Main window properties self.setWindowTitle("ILLIXR Visualizer") w = 1000 h = 600 self.resize(w, h) icon = QtGui.QIcon() illixr_img = QtGui.QPixmap("illixr_icon_square.png") #.scaled(64, 64, QtCore.Qt.KeepAspectRatio) icon.addPixmap(illixr_img, QtGui.QIcon.Normal, QtGui.QIcon.Off) self.setWindowIcon(icon) self.generalLayout = QGridLayout() self._centralWidget = QWidget(self) self.setCentralWidget(self._centralWidget) self._centralWidget.setLayout(self.generalLayout) self.has_figure = False self._createMenu(w) self._createDisplay() self._createPageNav() def _createMenu(self, w): """ The menu bar at the top of the app. Exposes the functionality for uploading the databases, altering plot settings, and saving the plot. """ self.menubar = QtWidgets.QMenuBar(self) self.menubar.setGeometry(QtCore.QRect(0, 0, w, 30)) self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setTitle("File") self.menuData = QtWidgets.QMenu(self.menubar) self.menuData.setTitle("Data") self.menuPlotSettings = QtWidgets.QMenu(self.menubar) self.menuPlotSettings.setTitle("Plot Settings") self.menuHelp = QtWidgets.QMenu(self.menubar) self.menuHelp.setTitle("Help") self.setMenuBar(self.menubar) # Add actions - sub categories of menu items self.actionNew = QtWidgets.QAction(self) self.actionNew.setText("New") self.actionSave = QtWidgets.QAction(self) self.actionSave.setText("Save") self.actionLoad = QtWidgets.QAction(self) self.actionLoad.setText("Load Data") self.actionLoad.setShortcut("Ctrl+L") self.actionLoad.triggered.connect(self._load) self.menuFile.addAction(self.actionNew) self.menuFile.addAction(self.actionSave) self.menuData.addAction(self.actionLoad) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuData.menuAction()) self.menubar.addAction(self.menuPlotSettings.menuAction()) self.menubar.addAction(self.menuHelp.menuAction()) def _createDisplay(self): """ The display is the interactive plot of the data. Starts out as an instructive label. """ self.displayLayout = QHBoxLayout() # Creates plugin list with title: self.pluginListLayout self._createPluginList() self.displayLayout.addLayout(self.pluginListLayout) # Create figure region: self.figureRegion self._createFigureRegion() self.displayLayout.addWidget(self.figureRegion, 1) # Only display stretches # Add full display to main window self.generalLayout.addLayout(self.displayLayout, 0, 0, 10, 23) def _createPluginList(self): """ Creates the left-hand reorderable Plugin list. """ self.pluginListLayout = QVBoxLayout() # Overall layout of this section # Label for plugin list pluginLabel = QLabel("Plugins") boldFont = QtGui.QFont() boldFont.setBold(True) pluginLabel.setFont(boldFont) pluginLabel.setAlignment(QtCore.Qt.AlignCenter) self.pluginListLayout.addWidget(pluginLabel) # Orderable plugin list self.pluginList = QListWidget() self.strList = ['No plugin names provided yet.', 'Load through Data menu option.'] self.pluginList.addItems(self.strList); self.pluginList.setDragDropMode(QAbstractItemView.InternalMove) self.pluginListLayout.addWidget(self.pluginList) # Button to reorder plot reorderButton = QPushButton('Reorder Plot') reorderButton.clicked.connect(self._reorder_plot) self.pluginListLayout.addWidget(reorderButton) def _createFigureRegion(self): """ Creates the right-hand figure display. """ # Embed figure within widget to create border self.figureRegion = QWidget() self.figureRegion.setStyleSheet("border: 1px solid darkgray") self.displaySubLayout = QVBoxLayout(self.figureRegion) self.displaySubLayout.setContentsMargins(1,1,1,1) # Create display plot region self.fig_view = QWebEngineView(self.figureRegion) self.set_display(text='No data provided yet. Load data in Data menu option.') # Add figure to sub layout self.displaySubLayout.addWidget(self.fig_view) def _createPageNav(self): """ Creates the navigation bar beneath the plot which enables the user to navigate between pages of the plot """ self.pageNavLayout = QHBoxLayout() self.pageNavLayout.addStretch() # Add arrows and icon self.left_button = QToolButton() self.left_button.setArrowType(QtCore.Qt.LeftArrow) self.left_button.clicked.connect(self._page_left) self.illixr_img = QLabel() pix_img = QtGui.QPixmap("illixr_icon.png").scaled(36, 36, QtCore.Qt.KeepAspectRatio) self.illixr_img.setPixmap(pix_img) self.right_button = QToolButton() self.right_button.setArrowType(QtCore.Qt.RightArrow) self.right_button.clicked.connect(self._page_right) self.pageNavLayout.addWidget(self.left_button) self.pageNavLayout.addWidget(self.illixr_img) self.pageNavLayout.addWidget(self.right_button) self.pageNavLayout.addStretch() self.generalLayout.addLayout(self.pageNavLayout, 10, 0, 1, 23) # END METHODS FOR INITIALIZING GUI def _load(self): """ Signals Controller to handle load. """ self.loadSignal.emit() def set_display(self, figure=None, text=None): """ Embeds given figure in the display. """ if figure is not None and text is not None: raise Exception("Only figure or text may be supplied.") html = '<html><head><meta charset="utf-8" />' if figure is not None: self.has_figure = True html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>' html += '<body>' # 'div' is specified for embedding the graph html += po.plot(figure, include_plotlyjs=False, output_type='div') elif text is not None and isinstance(text, str): html += '<body>' html += '<p style="font-family: sans-serif">' + text + '</p>' else: raise Exception("figure or text must be supplied.") html += '</body></html>' self.fig_view.setHtml(html) self.fig_view.raise_() def _page_left(self): """ Signals Controller to page left, updating the figure. """ if self.has_figure is True: self.leftSignal.emit() def _page_right(self): """ Signals Controller to page right, updating the figure. """ if self.has_figure is True: self.rightSignal.emit() def change_pagenum(self, pagenum : str): """ Changes the page number that is displayed in the page navigation bar. """ self.illixr_img.clear self.illixr_img.setText(pagenum) def _reorder_plot(self): """ Signals Controller to reorder the plugins in the plot. """ if self.has_figure is True: # Get the plugin names in order from list newPluginOrder = [] for i in range(self.pluginList.count()): newPluginOrder.append(self.pluginList.item(i).text()) self.strList = newPluginOrder self.reorderSignal.emit() def get_plugin_list(self): """ Returns the plugin list as it was last set, either by loading new data or clicking the Reorder Plot button. """ return self.strList def set_plugin_list(self, plugins : list): """ Sets the list of the plugins. """ self.pluginList.clear() self.strList = plugins self.pluginList.addItems(self.strList)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(1600, 1200) MainWindow.setAutoFillBackground(False) MainWindow.setStyleSheet("background-color: rgb(15, 45, 80);\n" "QPushButton { color: red }\n" "QLineEdit { color: red }\n" "QComboBox { color: red }\n" "") MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) MainWindow.setAnimated(True) MainWindow.setDockNestingEnabled(True) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.horizontalScrollBar = QtWidgets.QScrollBar(self.centralwidget) self.horizontalScrollBar.setGeometry(QtCore.QRect(10, 740, 761, 20)) self.horizontalScrollBar.setOrientation(QtCore.Qt.Horizontal) self.horizontalScrollBar.setObjectName("horizontalScrollBar") self.label_7 = QtWidgets.QLabel(self.centralwidget) self.label_7.setGeometry(QtCore.QRect(825, 480, 50, 51)) font = QtGui.QFont() font.setKerning(True) self.label_7.setFont(font) self.label_7.setAutoFillBackground(False) self.label_7.setFrameShape(QtWidgets.QFrame.NoFrame) self.label_7.setText("") self.label_7.setPixmap( QtGui.QPixmap("../../Blockchain_Schedule/Logos/circle2.png")) self.label_7.setScaledContents(True) self.label_7.setObjectName("label_7") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 762, 22)) self.menubar.setObjectName("menubar") self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.dockWidget = QtWidgets.QDockWidget(MainWindow) self.dockWidget.setObjectName("dockWidget") self.dockWidgetContents = QtWidgets.QWidget() self.dockWidgetContents.setObjectName("dockWidgetContents") self.dockWidget.setWidget(self.dockWidgetContents) MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockWidget) self.actionOpen_unsubmitted_Transaction = QtWidgets.QAction(MainWindow) self.actionOpen_unsubmitted_Transaction.setObjectName( "actionOpen_unsubmitted_Transaction") self.actionNew_Transaction = QtWidgets.QAction(MainWindow) self.actionNew_Transaction.setObjectName("actionNew_Transaction") self.menuFile.addAction(self.actionOpen_unsubmitted_Transaction) self.menuFile.addAction(self.actionNew_Transaction) self.menubar.addAction(self.menuFile.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.groupBox_2 = QtWidgets.QGroupBox(self.centralwidget) self.groupBox_2.setGeometry(QtCore.QRect(10, 20, 500, 250)) self.groupBox_2.setAutoFillBackground(False) self.groupBox_2.setStyleSheet("background-color: rgb(17, 50, 100);\n" "color: rgb(205, 250, 255); ") self.groupBox_2.setObjectName("groupBox_2") self.fileName = 'gantt.csv' self.model = QtGui.QStandardItemModel(self.groupBox_2) self.tableView = QtWidgets.QTableView(self.groupBox_2) self.tableView.setModel(self.model) self.tableView.horizontalHeader().setStretchLastSection(True) self.layoutVertical = QtWidgets.QVBoxLayout(self.groupBox_2) self.layoutVertical.addWidget(self.tableView) self.loadCsv(self.fileName) ########################-Chart-######################## #df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gantt_example.csv') df = pd.read_csv('gantt.csv') #fileName = 'gantt.csv' #loadCsv(self.fileName) colors = ['#7a0504', (0.2, 0.7, 0.3), 'rgb(205, 250, 255)'] fig = ff.create_gantt(df, colors=['rgb(160, 240, 255)', 'rgb(15, 45, 80)'], index_col='Complete', show_colorbar=True, bar_width=0.2, showgrid_x=True, showgrid_y=True) #fig = ff.create_gantt(df, colors=colors, index_col='Resource', reverse_colors=True,show_colorbar=True) #py.offline.plot(fig, filename='gantt2') #fig = go.Figure(data=[{'type': 'scattergl', 'y': [2, 1, 3, 1]}]) #######################Progress bars############## x1 = 1 print('time') print(df.iloc[:, 1]) print(df.iloc[1:1]) print(df.iloc[2:1]) print('start') print(df.iloc[1]['Start']) print('finish') print(df.iloc[1]['Finish']) total_rows = len(df.index) print('rows') print(total_rows) print('time') self.scrollarea = QtWidgets.QScrollArea(self.centralwidget) self.scrollarea.setGeometry(QtCore.QRect(50, 260, 900, 700)) #self.scrollarea.setFixedSize(250, 6000) self.scrollarea.setWidgetResizable(True) qtDate1 = QtCore.QDate.fromString(df.iloc[0]['Start'], 'yyyy-MM-dd') #get first date print(int(total_rows)) qtDate2 = QtCore.QDate.fromString(df.iloc[int(total_rows) - 1]['Finish'], 'yyyy-MM-dd') #get last date date2 = qtDate1.daysTo(qtDate2) print(date2) ra1 = 500 / date2 for i in range(total_rows): y1 = x1 * 30 + 60 print(df.iloc[i]['Start']) print(df.iloc[i]['Finish']) qtDate3 = QtCore.QDate.fromString(df.iloc[i]['Start'], 'yyyy-MM-dd') qtDate4 = QtCore.QDate.fromString(df.iloc[i]['Finish'], 'yyyy-MM-dd') date3 = qtDate3.daysTo(qtDate4) #calculate length of progress bar date5 = qtDate1.daysTo(qtDate3) #calculate start of progress bar print(date3) xp1 = 550 + int(date5) print("ratio") print(int(date2) / 500) #print(df.iloc[i]['Finish'] - df.iloc[i]['Start']) self.label_15 = QtWidgets.QLabel(self.centralwidget) self.label_15.setGeometry(QtCore.QRect(530, y1, 10, 20)) font = QtGui.QFont() font.setKerning(True) self.label_15.setFont(font) self.label_15.setAutoFillBackground(False) self.label_15.setFrameShape(QtWidgets.QFrame.NoFrame) self.label_15.setText("|") self.label_15.setStyleSheet("color: rgb(205, 250, 255); ") self.progressBar2 = QtWidgets.QProgressBar(self.centralwidget) self.progressBar2.setGeometry( QtCore.QRect(xp1, y1, int(date3) * ra1, 20)) print(int(date3) * ra1) complete1 = int(df.iloc[i]['Complete']) self.progressBar2.setProperty("value", complete1) self.progressBar2.setObjectName("progressBar2") self.progressBar2.setStyleSheet( "QProgressBar { border: 2px solid rgb(140, 230, 255); border-radius: 5px; color: rgb(255, 0, 25);}" "QProgressBar::chunk {background-color: rgb(205, 250, 255); color: rgb(255, 0, 25); width: 12px; margin: 0.5px;}" ) self.progressBar2.raise_() lines = QtGui.QPainter(self.centralwidget) #lines.setPen(QPen(Qt.green, 8, Qt.DashLine)) lines.setPen(QtCore.Qt.red) lines.setBrush(QtCore.Qt.white) #lines.drawLine(500,y1+80,1000,y1+80) lines.drawLine(500, 80, 1000, 80) x1 = x1 + 1 self.paintEvent(self) #######################Progress bars############## #######################GANTT############## raw_html = '<html><head><meta charset="utf-8" />' raw_html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>' raw_html += '<body>' raw_html += po.plot(fig, include_plotlyjs=False, output_type='div') raw_html += '</body></html>' #fig_view = QWebEngineView() #fig_view = QWebEngineView(self.groupBox_5) #fig_view = QWebEngineView(self.groupBox_5) fig_view = QWebEngineView(self.scrollarea) fig_view.setGeometry(QtCore.QRect(20, 20, 700, 700)) self.scrollarea.setWidget(fig_view) # setHtml has a 2MB size limit, need to switch to setUrl on tmp file # for large figures. fig_view.setHtml(raw_html) fig_view.show() fig_view.raise_()