Ejemplo n.º 1
0
class UiLayerArithmeticDialog(QDialog):
    def __init__(self, parent=None):
        super(UiLayerArithmeticDialog, self).__init__(parent)

        # Dialog settings
        self.setWindowTitle("Layer Arithmetic")
        self.resize(354, 134)

        self.layout_vertical = QVBoxLayout(self)

        # Arithmetic group box
        self.group_box_arithmetic = QGroupBox(self)
        self.group_box_arithmetic.setTitle("Formula")

        self.line_edit_formula = QLineEdit(self.group_box_arithmetic)

        self.layout_horizontal = QHBoxLayout(self.group_box_arithmetic)
        self.layout_horizontal.addWidget(self.line_edit_formula)
        self.layout_vertical.addWidget(self.group_box_arithmetic)

        # Buttons
        self.button_box = QDialogButtonBox(self)
        self.button_box.setOrientation(Qt.Horizontal)
        self.button_box.setStandardButtons(QDialogButtonBox.Cancel
                                           | QDialogButtonBox.Ok)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)

        self.layout_vertical.addWidget(self.button_box)
Ejemplo n.º 2
0
    def display_data(self, title, info, pos_x, pos_y, style):
        '''Build a data widget'''
        glay = QGridLayout()
        group = QGroupBox()

        countx = 0
        county = 0

        if style == 0:
            for text, channel in info.items():

                text_lb = QLabel(text, self)
                glay.addWidget(text_lb, countx, county)

                channel_lb = self.dataItem(channel, pos_y)
                channel_lb.showUnits = True
                glay.addWidget(channel_lb, countx, county + 1)

                countx += 1
        else:
            channel_lb = self.dataItem(info, pos_y)
            channel_lb.showUnits = True
            glay.addWidget(channel_lb, pos_x, pos_y)

        glay.setAlignment(Qt.AlignCenter)

        group.setTitle(title)
        group.setLayout(glay)

        return group
Ejemplo n.º 3
0
    def initUI(self):
        addFormulationButton = QPushButton()
        addFormulationButton.setText("Add formulation")
        addFormulationButton.setCursor(Qt.PointingHandCursor)
        self.addFormulationButton = addFormulationButton

        deleteFormulationButton = QPushButton()
        deleteFormulationButton.setText("Delete formulation")
        deleteFormulationButton.setObjectName("deleteFormulationButton")
        deleteFormulationButton.setDisabled(True)
        deleteFormulationButton.setCursor(Qt.ForbiddenCursor)
        self.deleteFormulationButton = deleteFormulationButton

        sortFormulationsButton = QPushButton()
        sortFormulationsButton.setText("Sort")
        sortFormulationsButton.setCursor(Qt.PointingHandCursor)
        self.sortFormulationsButton = sortFormulationsButton

        buttonsLayout = QHBoxLayout()
        buttonsLayout.addWidget(addFormulationButton)
        buttonsLayout.addWidget(deleteFormulationButton)
        buttonsLayout.addWidget(sortFormulationsButton)

        layout = QVBoxLayout()
        layout.addWidget(self.tableView, 1)
        layout.addLayout(buttonsLayout, 0)

        groupBox = QGroupBox()
        groupBox.setTitle("Formulations")
        groupBox.setLayout(layout)

        parentLayout = QVBoxLayout()
        parentLayout.addWidget(groupBox)
        self.setLayout(parentLayout)
Ejemplo n.º 4
0
    def initUI(self) -> None:
        noImageSetLabel = QLabel()
        noImageSetLabel.setObjectName("noImageSetLabel")
        noImageSetLabel.setAlignment(Qt.AlignCenter)
        noImageSetLabel.setText("No image selected")

        imageTableViewLayout = QVBoxLayout()
        imageTableViewLayout.addWidget(self.imageTableView)
        imageTableBox = QGroupBox()
        imageTableBox.setTitle("Images")
        imageTableBox.setLayout(imageTableViewLayout)

        imageTableSplitter = QSplitter()
        imageTableSplitter.setHandleWidth(12)
        imageTableSplitter.setOrientation(Qt.Vertical)
        imageTableSplitter.addWidget(imageTableBox)
        imageTableSplitter.setSizes([500, 500])
        self.imageTableSplitter = imageTableSplitter

        splitter = QSplitter()
        splitter.setHandleWidth(12)
        splitter.setObjectName("annotationSplitter")
        splitter.setOrientation(Qt.Horizontal)
        splitter.addWidget(imageTableSplitter)
        splitter.addWidget(noImageSetLabel)
        splitter.setSizes([200, 300])
        self.splitter = splitter

        layout = QVBoxLayout()
        layout.addWidget(splitter)
        self.setLayout(layout)
Ejemplo n.º 5
0
    def updateEditors(self, *, payloadsView: QWidget, blocksView: QWidget,
                      panelsView: QWidget, imagesView: QWidget) -> None:
        descriptionTextEdit = QPlainTextEdit()
        self.descriptionTextEdit = descriptionTextEdit

        descriptionLayout = QVBoxLayout()
        descriptionLayout.addWidget(descriptionTextEdit)

        descriptionBox = QGroupBox()
        descriptionBox.setTitle("Description")
        descriptionBox.setLayout(descriptionLayout)
        descriptionBox.setMaximumHeight(130)

        tabWidget = QTabWidget()
        tabWidget.setObjectName("settingsWidget")
        tabWidget.setTabPosition(QTabWidget.North)
        tabWidget.addTab(payloadsView, "Payloads")
        tabWidget.addTab(blocksView, "Blocks")
        tabWidget.addTab(panelsView, "Panels")
        tabWidget.addTab(imagesView, "Images")
        self.tabWidget = tabWidget

        layout = QVBoxLayout()
        layout.addWidget(descriptionBox, stretch=0)
        layout.addWidget(tabWidget, stretch=1)

        # replace no_project_selected_label with the settings layout
        parentLayout: QHBoxLayout = self.layout()
        item: QLayoutItem = parentLayout.takeAt(
            2)  # after statusWidget and spacer
        if item.widget() is not None:
            item.widget().deleteLater()
        parentLayout.addLayout(layout, stretch=1)
Ejemplo n.º 6
0
class UiSmoothingDialog(QDialog):
    """
    Initialize all the TopAxisDialog Qt UI elements.
    """
    def __init__(self, *args, **kwargs):
        super(UiSmoothingDialog, self).__init__(*args, **kwargs)
        size_policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        self.setSizePolicy(size_policy)

        # Dialog settings
        self.setWindowTitle("Smoothing Dialog")

        self.layout_vertical = QVBoxLayout(self)
        self.layout_horizontal = QHBoxLayout()
        self.layout_vertical.addLayout(self.layout_horizontal)

        # Define header selectors
        self.label_axis_mode = QLabel(self)
        self.combo_box_kernel = QComboBox(self)

        self.label_axis_mode.setText("Kernel")

        self.layout_horizontal.addWidget(self.label_axis_mode)
        self.layout_horizontal.addWidget(self.combo_box_kernel)
        self.layout_horizontal.setStretch(1, 1)

        # Define velocity
        self.group_box = QGroupBox(self)
        self.label_stddev = QLabel(self.group_box)
        self.line_edit_stddev = QLineEdit(self.group_box)

        self.group_box.setTitle("Parameters")
        self.label_stddev.setText("Standard Deviation")

        self.layout_horizontal_2 = QHBoxLayout(self.group_box)
        self.layout_horizontal_2.addWidget(self.label_stddev)
        self.layout_horizontal_2.addWidget(self.line_edit_stddev)

        self.layout_vertical.addWidget(self.group_box)

        # Add a spacer
        self.layout_vertical.addStretch(1)

        # Buttons
        self.button_box = QDialogButtonBox(self)
        self.button_box.setOrientation(Qt.Horizontal)
        self.button_box.setStandardButtons(QDialogButtonBox.Cancel
                                           | QDialogButtonBox.Ok)
        self.button_box.setObjectName("buttonBox")
        self.layout_vertical.addWidget(self.button_box)

        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
Ejemplo n.º 7
0
    def initUI(self):
        addSampleButton = QPushButton()
        addSampleButton.setText("Add sample")
        addSampleButton.setCursor(Qt.PointingHandCursor)
        self.addSampleButton = addSampleButton

        deleteSampleButton = QPushButton()
        deleteSampleButton.setText("Delete sample")
        deleteSampleButton.setObjectName("deleteSampleButton")
        deleteSampleButton.setDisabled(True)
        deleteSampleButton.setCursor(Qt.ForbiddenCursor)
        self.deleteSampleButton = deleteSampleButton

        sortSamplesButton = QPushButton()
        sortSamplesButton.setText("Sort")
        sortSamplesButton.setCursor(Qt.PointingHandCursor)
        self.sortSamplesButton = sortSamplesButton

        sampleButtonsLayout = QHBoxLayout()
        sampleButtonsLayout.addWidget(self.addSampleButton)
        sampleButtonsLayout.addWidget(self.deleteSampleButton)
        sampleButtonsLayout.addWidget(self.sortSamplesButton)

        addCohortButton = QPushButton()
        addCohortButton.setText("Add cohort")
        addCohortButton.setCursor(Qt.PointingHandCursor)
        self.addCohortButton = addCohortButton

        deleteCohortButton = QPushButton()
        deleteCohortButton.setText("Delete cohort")
        deleteCohortButton.setObjectName("deleteCohortButton")
        deleteCohortButton.setDisabled(True)
        deleteCohortButton.setCursor(Qt.ForbiddenCursor)
        self.deleteCohortButton = deleteCohortButton

        cohortButtonsLayout = QHBoxLayout()
        cohortButtonsLayout.addWidget(self.addCohortButton)
        cohortButtonsLayout.addWidget(self.deleteCohortButton)

        layout = QVBoxLayout()
        layout.addWidget(self.tableView)
        layout.addLayout(sampleButtonsLayout)
        layout.addLayout(cohortButtonsLayout)

        groupBox = QGroupBox()
        groupBox.setTitle("Samples")
        groupBox.setLayout(layout)

        parentLayout = QVBoxLayout()
        parentLayout.addWidget(groupBox)
        self.setLayout(parentLayout)
Ejemplo n.º 8
0
    def selectionItem(self, title, channel, orientation):
        '''Build a selection widget'''
        group = QGroupBox()
        lay = QVBoxLayout()

        selector = enum_button.PyDMEnumButton(init_channel=self.prefix +
                                              self.device_name + ":" + channel)
        selector.widgetType = 0
        selector.orientation = orientation
        lay.addWidget(selector, 0)

        group.setLayout(lay)
        group.setTitle(title)

        return group
Ejemplo n.º 9
0
    def displayTempGroup(self, pv_data, title):
        ''' Display one temperature group'''
        dtg_glay = QGridLayout()
        dtg_glay.setHorizontalSpacing(0)
        group = QGroupBox()
        count = [1, 1]

        dtg_glay = self.getSingleTitle(title, dtg_glay)
        for counter_prefix in range(1, pv_data[0][0] + 1):
            for counter_name in range(1, pv_data[0][1] + 1):
                pv_name = self.genStringTempPV(pv_data[1], counter_prefix,
                                               counter_name)

                dtg_glay.addLayout(self.tempMonBox(pv_name), count[0],
                                   count[1], 1, 1)
                count = self.updateCount(count, title)

        group.setTitle(title)
        group.setLayout(dtg_glay)

        return group
Ejemplo n.º 10
0
    def displayGroup(self, pv_data, title, group_type):
        ''' Display one MPS group '''
        dg_glay = QGridLayout()
        group = QGroupBox()
        count = [1, 1]

        dg_glay = self.getSingleTitle(title, dg_glay)
        index = 0
        for pv_name in pv_data.get('name'):
            if title != 'Gate Valve':
                if group_type == 0:
                    dg_glay.addLayout(
                        self.dispayHiddenControls(
                            pv_name,
                            self.getPVControl(pv_data.get('control'), index),
                            self.getPVConfig(pv_data.get('config'), index)),
                        count[0], count[1], 1, 1)
                else:
                    dg_glay.addLayout(
                        self.dispayAllControls(
                            pv_name,
                            self.getPVControl(pv_data.get('control'), index),
                            self.getPVConfig(pv_data.get('config'), index)),
                        count[0], count[1], 1, 1)
            else:
                dg_glay.addLayout(
                    self.gateValve(
                        pv_name, self.getPVConfig(pv_data.get('config'),
                                                  index)), count[0], count[1],
                    1, 1)
            count = self.updateCount(count, title)
            index += 1

        group.setTitle(title)
        group.setLayout(dg_glay)

        return group
Ejemplo n.º 11
0
    def __init__(self):
        super().__init__()

        self.labeledSlider = VLabeledSlider()

        self._qscene = QGraphicsScene()
        self._qscene.setSceneRect(-self._size / 2, -self._size / 2, self._size,
                                  self._size)

        self._qview = BlockDiagramView(scene=self._qscene, parent=self)

        layout = QHBoxLayout()
        layout.addWidget(self.labeledSlider, 0)
        layout.addWidget(self._qview, 1)
        layout.setAlignment(Qt.AlignCenter)
        self.widgetLayout = layout

        groupBox = QGroupBox()
        groupBox.setTitle("Block diagram")
        groupBox.setLayout(layout)

        parentLayout = QVBoxLayout()
        parentLayout.addWidget(groupBox)
        self.setLayout(parentLayout)
Ejemplo n.º 12
0
class UiTopAxisDialog(QDialog):
    """
    Initialize all the TopAxisDialog Qt UI elements.
    """
    def __init__(self, *args, **kwargs):
        super(UiTopAxisDialog, self).__init__(*args, **kwargs)
        self.setObjectName("Top Axis Dialog")

        size_policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        self.setSizePolicy(size_policy)

        # Dialog settings
        self.setWindowTitle("Axis Settings")

        self.layout_vertical = QVBoxLayout(self)
        self.layout_horizontal = QHBoxLayout()
        self.layout_vertical.addLayout(self.layout_horizontal)

        # Define header selectors
        self.label_axis_mode = QLabel(self)
        self.combo_box_axis_mode = QComboBox(self)

        self.label_axis_mode.setText("Axis mode")

        self.layout_horizontal.addWidget(self.label_axis_mode)
        self.layout_horizontal.addWidget(self.combo_box_axis_mode)

        # Define velocity
        self.group_box_velocity = QGroupBox(self)
        self.label_reference_wavelength = QLabel(self.group_box_velocity)
        self.line_edit_reference_wavelength = QLineEdit(
            self.group_box_velocity)

        self.group_box_velocity.setTitle("Velocity parameters")
        self.label_reference_wavelength.setText("Reference wavelength")

        self.layout_horizontal_2 = QHBoxLayout(self.group_box_velocity)
        self.layout_horizontal_2.addWidget(self.label_reference_wavelength)
        self.layout_horizontal_2.addWidget(self.line_edit_reference_wavelength)

        self.layout_vertical.addWidget(self.group_box_velocity)

        # Define redshift
        self.group_box_redshift = QGroupBox(self)
        self.label_redshift = QLabel(self.group_box_redshift)
        self.line_edit_redshift = QLineEdit(self.group_box_redshift)

        self.group_box_redshift.setTitle("Redshift parameters")
        self.label_redshift.setText("Amount")

        self.layout_horizontal_3 = QHBoxLayout(self.group_box_redshift)
        self.layout_horizontal_3.addWidget(self.label_redshift)
        self.layout_horizontal_3.addWidget(self.line_edit_redshift)

        self.layout_vertical.addWidget(self.group_box_redshift)

        # Add a spacer
        self.layout_vertical.addStretch(1)

        # Buttons
        self.button_box = QDialogButtonBox(self)
        self.button_box.setOrientation(Qt.Horizontal)
        self.button_box.setStandardButtons(QDialogButtonBox.Cancel
                                           | QDialogButtonBox.Ok)
        self.button_box.setObjectName("buttonBox")
        self.layout_vertical.addWidget(self.button_box)

        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
Ejemplo n.º 13
0
    def __init__(self, formulationsEditorView: FormulationsEditorView, *args, **kwargs):
        super().__init__(*args, **kwargs)

        longOrientLabel = QLabel("Longitudinal orientation:")
        longOrientCombo = QComboBox()
        longOrientCombo.addItems(
            [
                LongOrient.TipIntoPage.value,
                LongOrient.TipOutOfPage.value,
            ]
        )
        longOrientLabel.setBuddy(longOrientCombo)
        self.longOrientCombo = longOrientCombo

        longDirLabel = QLabel("Longitudinal direction:")
        longDirCombo = QComboBox()
        longDirCombo.addItems(
            [
                LongDir.IncreasingTowardsTip.value,
                LongDir.IncreasingTowardsBooster.value,
            ]
        )
        longDirLabel.setBuddy(longDirCombo)
        self.longDirCombo = longDirCombo

        angDirLabel = QLabel("Angular direction:")
        angDirCombo = QComboBox()
        angDirCombo.addItems([AngDir.Clockwise.value, AngDir.CounterClockwise.value])
        angDirLabel.setBuddy(angDirCombo)
        self.angDirCombo = angDirCombo

        notesTextEdit = QPlainTextEdit()
        self.notesTextEdit = notesTextEdit
        notesLayout = QHBoxLayout()
        notesLayout.addWidget(notesTextEdit)
        notesGroupBox = QGroupBox()
        notesGroupBox.setTitle("Notes")
        notesGroupBox.setLayout(notesLayout)
        notesGroupBox.setMaximumWidth(400)
        notesGroupBox.setMaximumHeight(200)

        layout = QGridLayout()
        layout.setColumnStretch(0, 0)
        layout.setColumnStretch(1, 1)

        layout.addWidget(longOrientLabel, 0, 0, Qt.AlignRight)
        layout.addWidget(longOrientCombo, 0, 1, Qt.AlignLeft)
        layout.setRowStretch(0, 0)

        layout.addWidget(longDirLabel, 1, 0, Qt.AlignRight)
        layout.addWidget(longDirCombo, 1, 1, Qt.AlignLeft)
        layout.setRowStretch(1, 0)

        layout.addWidget(angDirLabel, 2, 0, Qt.AlignRight)
        layout.addWidget(angDirCombo, 2, 1, Qt.AlignLeft)
        layout.setRowStretch(2, 0)

        layout.addWidget(formulationsEditorView, 3, 0, 1, 2)
        layout.setRowStretch(3, 1)

        layout.addWidget(notesGroupBox, 4, 0, 1, 2)
        layout.setRowStretch(4, 0)

        layout.addWidget(QWidget(), 5, 0)
        layout.setRowStretch(5, 0)

        parentWidget = QWidget()
        parentWidget.setLayout(layout)

        scrollArea = QScrollArea()
        scrollArea.setWidget(parentWidget)
        scrollArea.setWidgetResizable(True)

        parentLayout = QVBoxLayout()
        parentLayout.addWidget(scrollArea, 1)
        self.setLayout(parentLayout)
Ejemplo n.º 14
0
def createGroupBox(title):
    group_box = QGroupBox()
    group_box.setTitle(title)
    group_box_layout = QVBoxLayout(group_box)
    return group_box
Ejemplo n.º 15
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        selectProjectButton = QPushButton()
        selectProjectButton.setCursor(Qt.PointingHandCursor)
        selectProjectButton.setObjectName("selectProjectButton")
        selectProjectButton.setText("Select project")
        self.selectProjectButton = selectProjectButton

        pathLabel = QLabel()
        pathLabel.setText("Path:")
        pathLabel.setToolTip("Project path")
        pathLabel.setWordWrap(False)
        pathLabel.setAlignment(Qt.AlignRight)

        pathValueLabel = QElidedLabel()
        pathValueLabel.setText("none")
        pathValueLabel.setToolTip("none")
        pathValueLabel.setWordWrap(False)
        self.pathValueLabel = pathValueLabel

        nameLabel = QLabel()
        nameLabel.setText("Name:")
        nameLabel.setToolTip("Project name")
        nameLabel.setWordWrap(False)
        nameLabel.setAlignment(Qt.AlignRight)

        nameValueLabel = QElidedLabel()
        nameValueLabel.setText("none")
        nameValueLabel.setToolTip("none")
        nameValueLabel.setWordWrap(False)
        self.nameValueLabel = nameValueLabel

        projectStatusGrid = QGridLayout()
        projectStatusGrid.setContentsMargins(2, 2, 2, 2)
        projectStatusGrid.setColumnStretch(0, 0)
        projectStatusGrid.setColumnStretch(1, 1)
        projectStatusGrid.addWidget(pathLabel, 0, 0)
        projectStatusGrid.addWidget(nameLabel, 1, 0)
        projectStatusGrid.addWidget(pathValueLabel, 0, 1)
        projectStatusGrid.addWidget(nameValueLabel, 1, 1)

        projectGroupBox = QGroupBox()
        projectGroupBox.setTitle("Current project")
        projectGroupBox.setLayout(projectStatusGrid)

        statusLayout = QVBoxLayout()
        statusLayout.addWidget(selectProjectButton, stretch=0)
        statusLayout.addSpacing(10)
        statusLayout.addWidget(projectGroupBox, stretch=0)
        statusLayout.addStretch(1)
        statusLayout.setContentsMargins(0, 0, 0, 0)
        statusLayout.setSpacing(0)

        statusWidget = QWidget()
        statusWidget.setLayout(statusLayout)
        statusWidget.setContentsMargins(0, 0, 0, 0)
        statusWidget.setFixedWidth(250)

        noProjectSetLabel = QLabel()
        noProjectSetLabel.setObjectName("noProjectSetLabel")
        noProjectSetLabel.setText("No project set")
        noProjectSetLabel.setAlignment(Qt.AlignCenter)

        layout = QHBoxLayout()
        layout.setContentsMargins(6, 6, 6, 6)
        layout.addWidget(statusWidget, stretch=0)
        layout.addSpacing(3)
        layout.addWidget(noProjectSetLabel, stretch=1)

        self.setLayout(layout)
Ejemplo n.º 16
0
    def setup_ui(self):
        # Create the main layout
        main_layout = QVBoxLayout()
        self.setLayout(main_layout)

        # Create a Label to be the title
        lbl_title = QLabel("Motors Diagnostic")
        # Add some StyleSheet to it
        lbl_title.setStyleSheet("\
            QLabel {\
                qproperty-alignment: AlignCenter;\
                border: 1px solid #FF17365D;\
                border-top-left-radius: 15px;\
                border-top-right-radius: 15px;\
                background-color: #FF17365D;\
                padding: 5px 0px;\
                color: rgb(255, 255, 255);\
                max-height: 25px;\
                font-size: 14px;\
            }")

        # Add the title label to the main layout
        main_layout.addWidget(lbl_title)
        
        # Create the Search Panel layout
        search_layout = QHBoxLayout()
        
        # Create a GroupBox with "Filtering" as Title
        gb_search = QGroupBox(parent=self)
        gb_search.setTitle("Filtering")        
        gb_search.setLayout(search_layout)
        
        # Create a label, line edit and button for filtering
        lbl_search = QLabel(text="Filter: ")
        self.txt_filter = QLineEdit()
        self.txt_filter.returnPressed.connect(self.do_search)
        btn_search = QPushButton()
        btn_search.setText("Search")
        btn_search.clicked.connect(self.do_search)
        
        # Add the created widgets to the layout
        search_layout.addWidget(lbl_search)
        search_layout.addWidget(self.txt_filter)
        search_layout.addWidget(btn_search)

        # Add the Groupbox to the main layout
        main_layout.addWidget(gb_search)

        # Create the Results Layout
        self.results_layout = QVBoxLayout()
        self.results_layout.setContentsMargins(0, 0, 0, 0)

        # Create a Frame to host the results of search
        self.frm_result = QFrame(parent=self)       
        self.frm_result.setLayout(self.results_layout)

        # Create a ScrollArea so we can properly handle
        # many entries
        scroll_area = QScrollArea(parent=self)
        scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        scroll_area.setWidgetResizable(True)

        # Add the Frame to the scroll area
        scroll_area.setWidget(self.frm_result)

        # Add the scroll area to the main layout
        main_layout.addWidget(scroll_area)
Ejemplo n.º 17
0
    def initUi(self):
        self.setWindowTitle(u"回撤止损赢")

        labelStockCode = QLabel(u"代码")
        labelCrossDirection = QLabel(u"当正股")
        labelTradeDirection = QLabel(u"执行")
        labelVolume = QLabel(u"标的股")
        labelStockOwnerCode = QLabel(u"正股代码")
        labelStockOwnerDrawdownPct = QLabel(u"正股最大回撤%")
        labelOrderPrice = QLabel(u"下单价格")
        labelStartThreshold = QLabel(u"启动价格为")
        labelBeforeCloseTime = QLabel(u"收盘前(秒)")
        labelStockOwnerIncPct = QLabel(u"正股涨跌>%")
        labelKeepPositionPct = QLabel(u"保留仓位%")


        self.lineStockCode = QLineEdit()
        self.comboxTradeDirection = QComboBox()
        self.comboxTradeDirection.addItems(self.tradeDirection)
        self.comboxCrossDirection = QComboBox()
        self.comboxCrossDirection.addItems(self.crossDirection)
        self.lineVolume = QLineEdit()
        self.lineStockOwnerCode = QLineEdit()
        self.lineStockOwnerDrawdownPct = QLineEdit()
        self.comboxLineOrderPrice = QComboBox()
        self.comboxLineOrderPrice.addItems(self.orderPriceStrategy)
        self.comboxThresholdDirection = QComboBox()
        self.comboxThresholdDirection.addItems(self.thresholdDiection)
        self.lineThreadholdPirce = QLineEdit()
        self.lineBeforeCloseTime = QLineEdit()
        self.lineStockOwnerIncPct = QLineEdit()
        self.lineKeepPositionPct = QLineEdit()


        # 最上层 group box
        maxLenStockCode = 300
        maxLabelLen1 = 50
        gbTarget = QGroupBox()
        gbTarget.setTitle(u"标的股")
        hbox1 = QHBoxLayout()
        hbox1.addWidget(labelStockCode)
        hbox1.addWidget(self.lineStockCode)
        labelStockCode.setMaximumWidth(maxLabelLen1)
        self.lineStockCode.setMaximumWidth(maxLenStockCode)
        hbox1.addWidget(labelStockCode)
        hbox1.addWidget(self.lineStockCode)
        hbox1.addStretch()
        gbTarget.setLayout(hbox1)

        # 第二层 grid layout
        # line 0
        glayout = QGridLayout()
        gridMaxLen1 = 120
        gridMaxLen2 = 120
        glayout.addWidget(labelStockOwnerCode, 0, 0)
        glayout.addWidget(self.lineStockOwnerCode, 0, 1)
        glayout.addWidget(labelCrossDirection, 0 , 2)
        glayout.addWidget(self.comboxCrossDirection, 0, 3)
        glayout.addWidget(labelTradeDirection, 0 ,4)
        glayout.addWidget(self.comboxTradeDirection, 0, 5)
        glayout.addWidget(labelVolume, 0 ,6)
        glayout.addWidget(self.lineVolume, 0, 7)
        self.lineStockOwnerCode.setMaximumWidth(gridMaxLen1)
        self.comboxCrossDirection.setMaximumWidth(gridMaxLen2)
        self.comboxTradeDirection.setMaximumWidth(gridMaxLen2)
        self.lineVolume.setMaximumWidth(gridMaxLen2)
        # line 1
        glayout.addWidget(labelStockOwnerDrawdownPct, 1, 0)
        glayout.addWidget(self.lineStockOwnerDrawdownPct, 1, 1)
        glayout.addWidget(labelOrderPrice, 1, 2)
        glayout.addWidget(self.comboxLineOrderPrice, 1, 3)
        self.lineStockOwnerDrawdownPct.setMaximumWidth(gridMaxLen1)
        glayout.addWidget(labelStartThreshold, 1, 4)
        glayout.addWidget(self.comboxThresholdDirection, 1, 5)
        glayout.addWidget(self.lineThreadholdPirce, 1, 6)
        self.lineThreadholdPirce.setMaximumWidth(gridMaxLen1)
        # line 2
        glayout.addWidget(labelBeforeCloseTime, 2, 0)
        glayout.addWidget(self.lineBeforeCloseTime, 2, 1)
        glayout.addWidget(labelStockOwnerIncPct, 2, 2)
        glayout.addWidget(self.lineStockOwnerIncPct, 2, 3)
        glayout.addWidget(labelKeepPositionPct, 2, 4)
        glayout.addWidget(self.lineKeepPositionPct, 2, 5)
        self.lineBeforeCloseTime.setMaximumWidth(gridMaxLen1)
        self.lineStockOwnerIncPct.setMaximumWidth(gridMaxLen2)
        self.lineKeepPositionPct.setMaximumWidth(gridMaxLen2)

        # HBox layout for button
        hbox2 = QHBoxLayout()
        fixLenButton = 180
        space = 50
        btStart = QPushButton(u"启动策略")
        size = btStart.sizeHint()
        btStart.setMinimumHeight(size.height() * 2)
        btStopAll = QPushButton(u"停止全部策略")
        btStopAll.setMinimumHeight(size.height() * 2)
        hbox2.addWidget(btStart)
        # hbox2.addWidget(btStopAll)
        hbox2.addStretch()
        hbox2.setSpacing(space)
        btStart.setFixedWidth(fixLenButton)
        btStopAll.setFixedWidth(fixLenButton)

        vbox = QVBoxLayout()
        vbox.addWidget(gbTarget)
        vbox.addLayout(glayout)
        vbox.addLayout(hbox2)

        # 策略状态组件
        self.strategyWidget = StrategyStopOrderMonitor(self.stopOrderEngine, self.eventEngine)
        groupBoxStraMonitor = GroupBoxWithSinglWidget(self.strategyWidget, u"策略状态")
        vbox.addWidget(groupBoxStraMonitor)

        self.setLayout(vbox)

        btStart.clicked.connect(self.startStrategy)