예제 #1
0
 def __init__(self, parent, parent_widget, data=None, text='', file_path=None):
     self.parent = parent
     subWindow = QMdiSubWindow()
     self.sub_window = subWindow
     self.parent_widget = parent_widget
     loader = QUiLoader()
     pool = loader.load('stock_pool.ui', parentWidget=parent_widget)
     self.list = pool.findChild(QListWidget)
     self.grid_view = pool.findChild(QTableView)
     setattr(subWindow, "subWindowType", 3)
     setattr(subWindow, "btData", data)
     setattr(subWindow, "btFilePath", file_path)
     setattr(subWindow, "btPoolList", self.list)
     subWindow.setWindowTitle(u"股票池 - %s" % text)
     subWindow.setWidget(pool)
     parent.mdi_area.addSubWindow(subWindow)
     subWindow.setAttribute(Qt.WA_DeleteOnClose)
     subWindow.show()
예제 #2
0
    def __init__(self,
                 parent,
                 parent_widget,
                 data=None,
                 text='',
                 file_path=None):

        self.db = database.DataBase("stock")
        self.db.encryption("123qwe!#QWE")
        self.parent = parent
        subWindow = QMdiSubWindow()
        self.sub_window = subWindow
        self.parent_widget = parent_widget
        loader = QUiLoader()
        python_editor = loader.load('coding.ui', parentWidget=parent_widget)

        self.code_string = python_editor.findChild(QTextEdit, "code_string")

        self.result_display = python_editor.findChild(QTextEdit,
                                                      "result_display")

        python_editor.findChild(QToolButton).clicked.connect(
            lambda: self.onClickedFunctionButton())
        python_editor.findChild(
            QPushButton, "run").clicked.connect(lambda: self.onRunButton())
        python_editor.findChild(
            QPushButton,
            "cancel").clicked.connect(lambda: self.onCancelButton())

        self.code_string.textChanged.connect(lambda: self.onCodeChanged())
        if data:
            self.code_string.setPlainText(data)

        self.python_editor = python_editor

        setattr(subWindow, "subWindowType", 2)
        setattr(subWindow, "btData", '')
        setattr(subWindow, "btFilePath", file_path)
        subWindow.setWindowTitle(u"程序 - %s" % text)
        subWindow.setWidget(python_editor)
        parent.mdi_area.addSubWindow(subWindow)
        subWindow.setAttribute(Qt.WA_DeleteOnClose)
        subWindow.show()
예제 #3
0
    def __init__(self,
                 parent,
                 parent_widget,
                 config={},
                 text='',
                 file_path=None):
        self.parent = parent
        config = setting.SETTINGS if not config else config
        subWindow = QMdiSubWindow()
        loader = QUiLoader()
        backtest_management = loader.load('backtest_management.ui',
                                          parentWidget=parent_widget)
        action_delete_order = backtest_management.findChild(
            QAction, "delete_order")

        delete_backtest_tree_item = backtest_management.findChild(
            QAction, "action_delete")
        add_option_underlying = backtest_management.findChild(
            QAction, "action_add_option_underlying")
        add_option_group = backtest_management.findChild(
            QAction, "action_add_option_group")
        add_option_contract = backtest_management.findChild(
            QAction, "action_add_option_contract")
        no_support = backtest_management.findChild(QAction,
                                                   "action_no_support")

        tab_widget = backtest_management.findChild(QTabWidget)
        setattr(subWindow, "subWindowType", 1)
        setattr(subWindow, "btData", config)
        setattr(subWindow, "btFilePath", file_path)
        manual_tab.ManualSignal(tab_widget.widget(0), parent, config,
                                action_delete_order)
        signal_tab.SemiAutoSignal(tab_widget.widget(1), parent, config,
                                  delete_backtest_tree_item,
                                  add_option_underlying, add_option_group,
                                  add_option_contract, no_support)
        trade_tab.BackTest(tab_widget.widget(2), parent, config)
        subWindow.setWindowTitle(u"交易中心 - %s" % text)
        subWindow.setWidget(backtest_management)
        parent.mdi_area.addSubWindow(subWindow)
        subWindow.setAttribute(Qt.WA_DeleteOnClose)
        subWindow.show()
예제 #4
0
    def __init__(self, parent, parent_widget):
        self.parent = parent
        self.parent_widget = parent_widget

        has_sub_window = [
            i for i in self.parent.mdi_area.subWindowList()
            if i.windowTitle() == u"数据下载"
        ]
        if has_sub_window:
            return
        subWindow = QMdiSubWindow()
        loader = QUiLoader()
        data_center = loader.load('data_update.ui', parentWidget=parent_widget)

        tab_widgets = data_center.findChild(QTabWidget)
        ManualSignal(tab_widgets.widget(0), subWindow, parent.root)
        AutoUpdate(tab_widgets.widget(1), parent.root, parent.config)
        #
        subWindow.setWindowTitle(u"数据下载")
        subWindow.setWidget(data_center)
        parent.mdi_area.addSubWindow(subWindow)
        subWindow.setAttribute(Qt.WA_DeleteOnClose)
        subWindow.show()
예제 #5
0
    def open_tool(self, item, _):
        if not item.data(0, Qt.UserRole):
            return
        group = item.data(0, Qt.UserRole + 1)
        tool = item.data(0, Qt.UserRole + 2)
        for sub_window in self.mdi_area.subWindowList():
            if sub_window.windowTitle() == item.text(0):
                sub_window.setWindowState(Qt.WindowActive)
                sub_window.setFocus()
                return

        if group == 0:
            if tool == 0:
                tool_widget = OriginalWidget(self.image)
            elif tool == 1:
                tool_widget = DigestWidget(self.filename, self.image)
            elif tool == 2:
                tool_widget = EditorWidget()
            elif tool == 3:
                tool_widget = ReverseWidget()
            else:
                return
        elif group == 1:
            if tool == 0:
                tool_widget = HeaderWidget(self.filename)
            elif tool == 1:
                tool_widget = ExifWidget(self.filename)
            elif tool == 2:
                tool_widget = ThumbWidget(self.filename, self.image)
            elif tool == 3:
                tool_widget = LocationWidget(self.filename)
            else:
                return
        elif group == 2:
            if tool == 0:
                tool_widget = MagnifierWidget(self.image)
            elif tool == 1:
                tool_widget = HistWidget(self.image)
            elif tool == 2:
                tool_widget = AdjustWidget(self.image)
            elif tool == 3:
                tool_widget = ComparisonWidget(self.filename, self.image)
            else:
                return
        elif group == 3:
            if tool == 0:
                tool_widget = GradientWidget(self.image)
            elif tool == 1:
                tool_widget = EchoWidget(self.image)
            elif tool == 2:
                tool_widget = WaveletWidget(self.image)
            else:
                return
        elif group == 4:
            if tool == 0:
                tool_widget = PlotsWidget(self.image)
            elif tool == 1:
                tool_widget = SpaceWidget(self.image)
            elif tool == 2:
                tool_widget = PcaWidget(self.image)
            elif tool == 3:
                tool_widget = StatsWidget(self.image)
            else:
                return
        elif group == 5:
            if tool == 0:
                tool_widget = NoiseWidget(self.image)
            elif tool == 1:
                tool_widget = MinMaxWidget(self.image)
            elif tool == 2:
                tool_widget = FrequencyWidget(self.image)
            elif tool == 3:
                tool_widget = PlanesWidget(self.image)
            else:
                return
        elif group == 6:
            if tool == 0:
                tool_widget = ElaWidget(self.image)
            elif tool == 1:
                tool_widget = QualityWidget(self.filename)
            elif tool == 2:
                tool_widget = MultipleWidget(self.image)
            else:
                return
        elif group == 7:
            if tool == 0:
                tool_widget = ContrastWidget(self.image)
            elif tool == 1:
                tool_widget = CloningWidget(self.image)
            elif tool == 2:
                # tool_widget = ResamplingWidget(self.image)
                pass
            else:
                return
        elif group == 8:
            if tool == 3:
                tool_widget = StereoWidget(self.image)
            else:
                return
        else:
            return

        # FIXME: Aggiungere un metodo init e dopo fare il connect, sennò i messaggi inviati nel costruttore non si vedono
        tool_widget.info_message.connect(self.show_message)

        sub_window = QMdiSubWindow()
        sub_window.setWidget(tool_widget)
        sub_window.setWindowTitle(item.text(0))
        sub_window.setObjectName(item.text(0))
        sub_window.setAttribute(Qt.WA_DeleteOnClose)
        sub_window.setWindowIcon(QIcon('icons/{}.svg'.format(group)))
        self.mdi_area.addSubWindow(sub_window)
        sub_window.show()
        sub_window.destroyed.connect(self.disable_bold)
        self.tree_widget.set_bold(item.text(0), enabled=True)
예제 #6
0
    def __init__(self,
                 parent,
                 title,
                 data,
                 id=0,
                 hidden_columns=[],
                 index_column=None,
                 childSubWindow={},
                 type=1,
                 file_path=None):
        """

                :param title: Window title
                :param data: Table show data
                :param hidden_columns: Columns to be hidden
                :param index_column: which column is index column
                :param childSubWindow: When double click each row, which child table should be opened
                        Sample:  {
                                    "title":"",
                                    "type": "table",
                                    "table_name": "option/underlyings/%underlying_order_book_id%",
                                    "where:"",
                                    "select":"",
                                    "hidden_columns":[],
                                    "index_column":[],
                                    "childSubWindow":{},
                                }

                :return:
                """
        self.parent = parent
        self.window = parent.window
        self.mdi_area = parent.mdi_area
        if index_column:
            data.index = list(data[index_column])
            data.index.name = index_column
        subWindow = QMdiSubWindow()
        setattr(subWindow, "subWindowType", 0)
        setattr(subWindow, "btData", data)
        setattr(subWindow, "btId", id)
        setattr(subWindow, "btType", type)
        setattr(subWindow, "btFilePath", file_path)
        setattr(subWindow, "childSubWindow", childSubWindow)
        setattr(subWindow, "hidden_columns", hidden_columns)

        tableView = QTableView()

        # 双击列的信号
        tableView.horizontalHeader().sectionDoubleClicked.connect(
            lambda event: self.onTableViewColumnDoubleClicked(event, None))
        # 双击行的信号
        tableView.verticalHeader().sectionDoubleClicked.connect(
            self.onTableViewRowDoubleClicked)
        # 双击cell的信号
        tableView.doubleClicked.connect(self.onTableViewCellDoubleClicked)

        # 右键列
        headers = tableView.horizontalHeader()
        headers.setContextMenuPolicy(Qt.CustomContextMenu)
        headers.customContextMenuRequested.connect(
            lambda event: self.onTableViewColumnClicked(event, tableView))
        headers.setSelectionMode(QAbstractItemView.SingleSelection)

        cornerButton = tableView.findChild(QAbstractButton)
        cornerButton.customContextMenuRequested.connect(
            self.onCornerButtonRightClicked)

        tableView.setWindowTitle(title)
        tableView.setWindowIcon(QtGui.QIcon("../icon/sheet.png"))

        proxyModel = QtCore.QSortFilterProxyModel(subWindow)
        mode = pandas_mode.PandasModel(data)
        proxyModel.setSourceModel(mode)
        tableView.setModel(proxyModel)

        self._hide_columns(tableView, data, hidden_columns)

        systemMenu = subWindow.systemMenu()
        last_action = systemMenu.actions()[-1]
        display_setting = self.window.findChild(QAction, "display_action")
        systemMenu.insertAction(last_action, display_setting)

        subWindow.setAttribute(Qt.WA_DeleteOnClose)
        subWindow.setWidget(tableView)
        self.mdi_area.addSubWindow(subWindow)

        subWindow.show()