コード例 #1
0
 def __init__(self):
     QMdiSubWindow.__init__(self)
     self.setWindowFlag(Qt.WindowMaximizeButtonHint, False)
     self.setLayout(QHBoxLayout())
     self.main_frame = EasyFrame()
     self.main_frame.setMouseTracking(True)
     super().layout().addWidget(self.main_frame)
     self.main_frame.setLayout(QGridLayout())
コード例 #2
0
 def set_table_win(self):
     # Add data table sub-window
     self.data_table = DataTable(self.exp, self)
     self.data_table.signals.plot.connect(self.replot)
     self.DataTableWindow = QMdiSubWindow()
     self.DataTableWindow.setWidget(self.data_table)
     self.ui.mdiArea.addSubWindow(self.DataTableWindow)
     self.DataTableWindow.show()
コード例 #3
0
    def __init__(self, empty: bool = False):
        QMdiSubWindow.__init__(self)
        self.setWindowFlag(Qt.WindowMaximizeButtonHint, False)
        if not empty:
            self.setLayout(QHBoxLayout())
            self.main_frame = EasyFrame()
            self.main_frame.setMouseTracking(True)
            super().layout().addWidget(self.main_frame)
            self.main_frame.setLayout(QGridLayout())
            self.layout = self.new_layout

            self._icon = QIcon(image_file_path + "rs_icon.png")
            self.setWindowIcon(self._icon)
コード例 #4
0
 def set_param_win(self):
     # Add analysis parameters
     self.analysis_parameters = Parameter(self.exp, self)
     self.analysis_parameters.signals.plot.connect(self.replot)
     self.ParameterWindow = QMdiSubWindow()
     self.ParameterWindow.setWidget(self.analysis_parameters)
     self.ui.mdiArea.addSubWindow(self.ParameterWindow)
     self.ParameterWindow.show()
     # Add note window
     self.exp_notes = Notes(self.exp, self)
     self.NotesWindow = QMdiSubWindow()
     self.NotesWindow.setWidget(self.exp_notes)
     self.ui.mdiArea.addSubWindow(self.NotesWindow)
     self.NotesWindow.show()
コード例 #5
0
 def newSlot(self):
     self.count += 1
     sub = QMdiSubWindow()
     sub.setWidget(QTextEdit())
     sub.setWindowTitle("Sub Window " + str(self.count))
     self.mdi.addSubWindow(sub)
     sub.show()
コード例 #6
0
ファイル: __init__.py プロジェクト: fj11/backtesters
 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()
コード例 #7
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()
コード例 #8
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()
コード例 #9
0
 def set_figs_win(self):
     # Add plots
     self.FigureWindows = {}
     self.figs = {}
     _figs = self.exp.get_figures()
     for _name in _figs.keys():
         self.figs[_name] = MplCanvas(_figs[_name])
         self.FigureWindows[_name] = QMdiSubWindow()
         self.FigureWindows[_name].setWidget(self.figs[_name])
         self.FigureWindows[_name].resize(500, 400)
         self.ui.mdiArea.addSubWindow(self.FigureWindows[_name])
         self.FigureWindows[_name].show()
コード例 #10
0
    def windowTriggered(self, p):
        if p.text() == "New":
            Window.count = Window.count + 1
            sub = QMdiSubWindow()
            sub.setWidget(QTextEdit())
            sub.setWindowTitle("Sub Window " + str(Window.count))
            self.mdi.addSubWindow(sub)
            sub.show()

        if p.text() == "Cascade":
            self.mdi.cascadeSubWindows()

        if p.text() == "Tiled":
            self.mdi.tileSubWindows()
コード例 #11
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()
コード例 #12
0
    def initUI(self):
        widget = self.initSubWindow()

        sub_window = QMdiSubWindow()
        sub_window.setWidget(widget)
        sub_window.setWindowTitle("MdiSubWindow")

        self.mdiArea = QMdiArea()
        self.setCentralWidget(self.mdiArea)
        self.mdiArea.addSubWindow(sub_window)
        self.setWindowTitle("MdiArea")
コード例 #13
0
ファイル: sherloq.py プロジェクト: FreshMilkDaddy/sherloq
    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)
コード例 #14
0
ファイル: mdisubwindow.py プロジェクト: testalucida/python
 def __init__(self):
     QMdiSubWindow.__init__(self)
     self._quitCallbackList = []
コード例 #15
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()
コード例 #16
0
 def __init__(self, widget: QWidget, title: str, id: Any):
     QMdiSubWindow.__init__(self)
     self._id = id
     self.setWidget(widget)
     self.setWindowTitle(title)
コード例 #17
0
class MainWindow(QMainWindow):
    def __init__(self, exp):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.setWindowIcon(QIcon('icons/main.ico'))

        # Setup status bar. Cannot do this in the Designer.
        self.btn_idle = QPushButton("Record", self)
        self.btn_idle.setStyleSheet("background-color : red")
        self.btn_idle.setCheckable(True)
        self.ui.statusbar.addWidget(self.btn_idle)

        self.exp = exp
        self.threadpool = QThreadPool()

        # Setup the GUI windows
        # self.showMaximized()
        self.set_windows()

        # Menu bar function binding
        self.ui.actionNew.triggered.connect(self.OnNewExperiment)
        self.ui.actionOpen.triggered.connect(self.OnOpenExperiment)
        self.ui.actionSave.triggered.connect(self.OnSaveExperiment)
        self.ui.actionTileWindows.triggered.connect(self.OnTileWindows)
        self.ui.actionOpenWindows.triggered.connect(self.OnShowWindows)
        self.ui.actionLoadScript.triggered.connect(self.OnLoadScript)
        self.ui.actionReloadScript.triggered.connect(self.OnReloadScript)
        # Status bar
        self.btn_idle.clicked.connect(self.OnRecord)
        # Keyboard shortcuts
        self.full_screen = False
        self.shortcut_full_screen = QShortcut(QKeySequence('F11'), self)
        self.shortcut_full_screen.activated.connect(self.OnFullScreen)

        # Start looking for data files
        self.start_file_thread()
        self.start_plot_thread()

        self.showMaximized()  # Open the application in full screen mode
        self.show()

    def set_table_win(self):
        # Add data table sub-window
        self.data_table = DataTable(self.exp, self)
        self.data_table.signals.plot.connect(self.replot)
        self.DataTableWindow = QMdiSubWindow()
        self.DataTableWindow.setWidget(self.data_table)
        self.ui.mdiArea.addSubWindow(self.DataTableWindow)
        self.DataTableWindow.show()

    def set_param_win(self):
        # Add analysis parameters
        self.analysis_parameters = Parameter(self.exp, self)
        self.analysis_parameters.signals.plot.connect(self.replot)
        self.ParameterWindow = QMdiSubWindow()
        self.ParameterWindow.setWidget(self.analysis_parameters)
        self.ui.mdiArea.addSubWindow(self.ParameterWindow)
        self.ParameterWindow.show()
        # Add note window
        self.exp_notes = Notes(self.exp, self)
        self.NotesWindow = QMdiSubWindow()
        self.NotesWindow.setWidget(self.exp_notes)
        self.ui.mdiArea.addSubWindow(self.NotesWindow)
        self.NotesWindow.show()

    def set_figs_win(self):
        # Add plots
        self.FigureWindows = {}
        self.figs = {}
        _figs = self.exp.get_figures()
        for _name in _figs.keys():
            self.figs[_name] = MplCanvas(_figs[_name])
            self.FigureWindows[_name] = QMdiSubWindow()
            self.FigureWindows[_name].setWidget(self.figs[_name])
            self.FigureWindows[_name].resize(500, 400)
            self.ui.mdiArea.addSubWindow(self.FigureWindows[_name])
            self.FigureWindows[_name].show()

    def set_windows(self):
        self.set_table_win()
        self.set_param_win()
        self.set_figs_win()
        self.OnTileWindows()

    def clear_windows(self, subwindows='all'):
        if subwindows == 'all':
            subwindows = self.ui.mdiArea.subWindowList()
        for _win in subwindows:
            self.ui.mdiArea.removeSubWindow(_win)

    def refresh_windows(self):
        self.clear_windows()
        self.set_windows()

    def start_file_thread(self):
        # Start file thread
        self.file_thread = FileThread(self.exp, self)
        self.file_thread.signals.result.connect(self.add_result)
        self.file_thread.start()

    def stop_file_thread(self):
        self.file_thread.abort()

    def start_plot_thread(self):
        self.plot_thread = PlotThread(self)
        self.plot_thread.start()

    def stop_plot_thread(self):
        self.plot_thread.abort()

    @Slot()
    def replot(self):
        self.plot_thread.replot()

    @Slot()
    def OnFullScreen(self):
        if self.full_screen:
            self.showMaximized()
        else:
            self.showFullScreen()
        self.full_screen = not self.full_screen

    @Slot()
    def OnTileWindows(self):
        _win_width = self.ui.mdiArea.width()  # Window width

        top_row_height = 450
        _table_win_width = max(1200, _win_width * 0.65)
        _param_win_width = 3. / 7. * (_win_width - _table_win_width)
        _notes_win_width = (_win_width - _table_win_width - _param_win_width)
        # Position table window
        _ract = QRect(0., 0., _table_win_width, top_row_height)
        self.DataTableWindow.setGeometry(_ract)
        self.DataTableWindow.move(0, 0)
        # Positon parameter window
        _ract = QRect(0., 0., _param_win_width, top_row_height)
        self.ParameterWindow.setGeometry(_ract)
        self.ParameterWindow.move(_table_win_width, 0)
        # Position Note window
        _ract = QRect(0., 0., _notes_win_width, top_row_height)
        self.NotesWindow.setGeometry(_ract)
        self.NotesWindow.move(_table_win_width + _param_win_width, 0)

        # Tile figure windwos
        _fig_win_size = _win_width / 4.
        for ii, _name in enumerate(self.FigureWindows.keys()):
            x_shift = ii % 4
            y_shift = math.floor(ii / 4)
            _rect = QRect(0., 0., _fig_win_size, _fig_win_size)
            self.FigureWindows[_name].setGeometry(_rect)
            self.FigureWindows[_name].move(
                _fig_win_size * x_shift,
                _fig_win_size * y_shift + top_row_height)

    @Slot()
    def OnShowWindows(self):
        self.refresh_windows()

    @Slot()
    def OnNewExperiment(self):
        self.OnSaveExperiment()
        _info = self.exp.get_exp_info()
        _name = _info['name']
        _script = os.path.join(_info['script_dir'], _info['script'])

        dlg = NewExpDialog(name=_name, script=_script)

        if dlg.exec_():
            _name = dlg.get_name()
            _script = dlg.get_script()
            self.exp = Experiment(name=_name, script=_script)
            self.file_thread.set_experiment(self.exp)
            self.clear_windows()
            self.set_windows()

    @Slot()
    def OnOpenExperiment(self):
        dlg = QFileDialog()
        dlg.setNameFilter("Experiment (*.info)")
        if dlg.exec_():
            dirname = dlg.selectedFiles()[0]
            dirname = dirname.replace(
                '/', '\\'
            )  # Convert to Windows path. Maybe use pathlib in the future
            exp = load_exp(dirname)
            self.exp = exp
            self.file_thread.set_experiment(self.exp)
            self.clear_windows()
            self.set_windows()

    @Slot()
    def OnSaveExperiment(self):
        self.exp.save()

    @Slot()
    def OnLoadScript(self):
        dlg = QFileDialog()
        dlg.setNameFilter("Script (*.ipynb)")
        if dlg.exec_():
            _script = dlg.selectedFiles()[0]
            self.exp.set_analysis_script(_script)
            self.clear_windows()
            self.set_windows()

    @Slot()
    def OnReloadScript(self):
        # Load from data folder instead of script folder
        _script = os.path.join(self.exp.exp_dir, self.exp.script_filename)
        if self.exp.script_filename.strip() == '':
            console_print(
                'Main Window',
                'Unknown scrit file! Use "Load Script" in the "Analysis" Menu.'
                .format(_script),
                method='error')
            return
        if not os.path.exists(_script):
            console_print('Main Window',
                          'Script ({}) doesn\'t exist!'.format(_script))
            return
        _params = self.exp.get_parameters(
        )  # Preserve the parameters when reload
        self.exp.set_analysis_script(_script)
        self.clear_windows()
        self.set_windows()
        self.analysis_parameters.set_parameters(
            _params)  # Set to current parameters

    @Slot()
    def OnRecord(self):
        _status = self.btn_idle.isChecked()
        if self.file_thread == None:  # Restart the file thread if it crashed
            self.start_file_thread()
        self.file_thread.set_save(_status)
        if _status:
            self.btn_idle.setStyleSheet("background-color : green")
        else:
            self.btn_idle.setStyleSheet("background-color : red")
        return 1

    @Slot(int)
    def add_result(self, data_id):
        self.data_table.add_run(data_id)
        self.replot()

    @Slot()
    def update_figures(self):  # Refresh the GUI for new figures.
        for _name in self.figs.keys():
            self.figs[_name].draw()
        return 1

    def load_analysis_script(self, filename):
        self.exp.set_analysis_script(filename)
        # self.ui.mdiArea.removeSubWindow(self.ParameterWindow)
        self.analysis_parameters = Parameter(self.exp, self)
        self.ParameterWindow.setWidget(self.analysis_parameters)