示例#1
0
    def __init__(self, listeners_pool, *args, **kwargs):
        super(Summatory, self).__init__(*args, **kwargs)
        ListenerNode.__init__(self, 'sum-text', listeners_pool)

        self.lbl = self.create_label(22)
        self.lbl2 = self.create_label(12)

        layout = QVBoxLayout()
        self.setLayout(layout)

        inner_layout = QVBoxLayout()
        inner_layout.addWidget(self.lbl)
        inner_layout.addWidget(self.lbl2)

        group_box = QGroupBox("Sumatorio")
        group_box.setLayout(inner_layout)

        layout.addWidget(group_box)

        self.set_sum_value(0.0)
        self.set_records_no_value(0)
class Dialog(QDialog):
    def __init__(self):
        super().__init__()
        self.createFormGroupBox()
        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        mainLayout = QVBoxLayout()
        mainLayout.addWidget(self.formGroupBox)
        mainLayout.addWidget(buttonBox)
        self.setLayout(mainLayout)
        self.setWindowTitle("user info")

    def createFormGroupBox(self):
        self.formGroupBox = QGroupBox("your infomation")
        layout = QFormLayout()
        layout.addRow(QLabel("name:"), QLineEdit())
        layout.addRow("age:", QSpinBox())
        layout.addRow(QLabel("other infomation:"), QTextEdit())
        self.formGroupBox.setLayout(layout)
示例#3
0
    def initImageLayout(self):

        self.hImageGroupBox = QGroupBox()
        imageLayout = QGridLayout()

        imageSourceGroupBox = QGroupBox()
        imageResultGroupBox = QGroupBox()

        imgx, imgy = self.scale
        self.texts = []
        for i in range(1):
            text = ClickLabel(self, i, "None")
            text.setAlignment(Qt.AlignTop)
            # text.setFixedSize(QSize(imgx, imgy))
            self.texts.append(text)

        text = ClickLabel(self, 1, "")
        text.setAlignment(Qt.AlignTop)
        # text.setFixedSize(QSize(imgx, imgy))
        self.texts.append(text)

        texts = self.texts[:3] + self.texts[-1:]

        imageSourceLayout = QHBoxLayout()
        imageSourceLayout.setAlignment(Qt.AlignCenter)
        imageSourceLayout.addWidget(texts[0])
        imageSourceGroupBox.setLayout(imageSourceLayout)
        imageResultLayout = QHBoxLayout()
        imageResultLayout.setAlignment(Qt.AlignCenter)
        imageResultLayout.addWidget(texts[1])
        imageResultGroupBox.setLayout(imageResultLayout)

        imageLayout.addWidget(imageSourceGroupBox, 0, 0)
        imageLayout.addWidget(imageResultGroupBox, 0, 1)

        self.pageLabel = QLabel('0 / 0')
        self.pageLabel.setFixedHeight(10)
        self.pageLabel.setAlignment(Qt.AlignCenter)
        imageLayout.addWidget(self.pageLabel, 1, 0)
        self.hImageGroupBox.setLayout(imageLayout)
示例#4
0
    def __set_outputs_ui(self):
        group_box = QGroupBox('Training Details')
        inner_layout = QFormLayout()
        group_box.setLayout(inner_layout)

        self.current_iter_time = QLabel('--')
        self.current_error = QLabel('--')
        self.avg_error = QLabel('--')
        self.global_best_error = QLabel('--')
        self.total_best_error = QLabel('--')
        self.progressbar = QProgressBar()

        self.current_iter_time.setAlignment(Qt.AlignCenter)
        self.current_error.setAlignment(Qt.AlignCenter)
        self.avg_error.setAlignment(Qt.AlignCenter)
        self.global_best_error.setAlignment(Qt.AlignCenter)
        self.total_best_error.setAlignment(Qt.AlignCenter)

        self.current_iter_time.setStatusTip('The current iterating time of '
                                            'the PSO.')
        self.current_error.setStatusTip('The current error from the fitting '
                                        'function. ("( )": normalized error)')
        self.avg_error.setStatusTip('The average error from the fitting '
                                    'function in current iteration.  ("( )": '
                                    'normalized error)')
        self.global_best_error.setStatusTip(
            'The error of global best individual from the fitting function in '
            'current iteration.  ("( )": normalized error)')
        self.total_best_error.setStatusTip(
            'The error of total best individual from the fitting function in '
            'training.  ("( )": normalized error)')

        inner_layout.addRow('Current Iterating Time:', self.current_iter_time)
        inner_layout.addRow('Current Error:', self.current_error)
        inner_layout.addRow('Average Error:', self.avg_error)
        inner_layout.addRow('Global Best Error:', self.global_best_error)
        inner_layout.addRow('Total Best Error:', self.total_best_error)
        inner_layout.addRow(self.progressbar)

        self._layout.addWidget(group_box)
示例#5
0
 def init_font_settings(self, text_item):
     font_layout = QVBoxLayout()
     font_layout.setAlignment(Qt.AlignTop)
     font_layout.addWidget(QLabel("Family"))
     font_layout.addWidget(init_font_families_widget(text_item))
     font_layout.addWidget(QLabel("Size"))
     font_layout.addLayout(init_font_size_layout(text_item))
     font_layout.addWidget(QLabel("Color"))
     font_layout.addWidget(init_font_color_widget(text_item))
     font_layout.addWidget(QLabel("Style"))
     font_layout.addWidget(init_font_style_widget(text_item))
     font_layout.addWidget(QLabel("Weight"))
     font_layout.addWidget(init_font_weight_widget(text_item))
     font_layout.addWidget(QLabel("Capitalization"))
     font_layout.addWidget(init_capitalization_widget(text_item))
     font_layout.addWidget(QLabel("Stretch"))
     font_layout.addWidget(init_stretch_layout(text_item))
     font_layout.addWidget(init_kerning_widget(text_item))
     font_layout.addWidget(init_overline_widget(text_item))
     font_layout.addWidget(init_strikeout_widget(text_item))
     font_layout.addWidget(init_underline_widget(text_item))
     font_layout.addWidget(init_letter_spacing_widget(text_item))
     font_group_box = QGroupBox("Font")
     font_group_box.setLayout(font_layout)
     layout = QVBoxLayout()
     layout.addWidget(font_group_box)
     text_item_group_box = QGroupBox("Text item")
     text_item_layout = QVBoxLayout()
     text_item_layout.setAlignment(Qt.AlignTop)
     text_item_layout.addLayout(
         init_item_opacity_layout(text_item))
     text_item_layout.addLayout(init_item_rotation_layout(text_item))
     text_item_group_box.setLayout(text_item_layout)
     layout.addWidget(text_item_group_box)
     layout.addWidget(self.init_item_duplicate_widget(text_item))
     layout.addWidget(init_item_delete_widget(text_item))
     settings = QWidget()
     settings.setLayout(layout)
     self.settings_scroll_area.setWidget(settings)
     self.layout.setCurrentWidget(self.settings_scroll_area)
示例#6
0
    def __setVariableDisplayUI(self):
        group_box = QGroupBox("Monitor")
        self.__layout.addWidget(group_box)
        inner_layout = QFormLayout()
        group_box.setLayout(inner_layout)

        self.car_position = QLabel("(0, 0)")
        self.car_angle = QLabel("0")
        self.wheel_angle = QLabel("0.0")
        self.dist_front = QLabel("--")
        self.dist_left = QLabel("--")
        self.dist_right = QLabel("--")
        self.dist_lrdiff = QLabel("--")

        self.car_position.setAlignment(Qt.AlignCenter)
        self.car_angle.setAlignment(Qt.AlignCenter)
        self.wheel_angle.setAlignment(Qt.AlignCenter)
        self.dist_front.setAlignment(Qt.AlignCenter)
        self.dist_left.setAlignment(Qt.AlignCenter)
        self.dist_right.setAlignment(Qt.AlignCenter)
        self.dist_lrdiff.setAlignment(Qt.AlignCenter)

        self.car_angle_label = QLabel("Car Angle:")
        self.wheel_angle_label = QLabel("Wheel Angle:")
        self.car_angle_label.setStatusTip("The angle (degree) of car between "
                                          "x-axis.")
        self.wheel_angle_label.setStatusTip("The angle (degree) of the wheel "
                                            "of car between x-axis, which "
                                            "will determine the next position "
                                            "of the car.")

        inner_layout.addRow(QLabel("Car Position:"), self.car_position)
        inner_layout.addRow(self.car_angle_label, self.car_angle)
        inner_layout.addRow(self.wheel_angle_label, self.wheel_angle)
        inner_layout.addRow(QLabel("Front Distance:"), self.dist_front)
        inner_layout.addRow(QLabel("Left Distance:"), self.dist_left)
        inner_layout.addRow(QLabel("Right Distance:"), self.dist_right)
        inner_layout.addRow(
            QLabel("(Left - Right) Distance:"), self.dist_lrdiff)
示例#7
0
    def __set_graphic_ui(self):
        group_box = QGroupBox('Error Line Charts:')
        inner_layout = QVBoxLayout()
        group_box.setLayout(inner_layout)

        self.err_chart = ErrorLineChart(1)
        self.err_chart.setStatusTip('The history of error from the fitting '
                                    'of the PSO for each data.')
        self.__err_x = 1

        self.iter_err_chart = ErrorLineChart(
            3, ('Avg', 'Global Best', 'Total Best'))
        self.iter_err_chart.setStatusTip('The history of average and least '
                                         'error from the fitting of the PSO '
                                         'for each iteration.')
        self.iter_err_chart.setMinimumHeight(150)

        inner_layout.addWidget(QLabel('Current Error'))
        inner_layout.addWidget(self.err_chart)
        inner_layout.addWidget(QLabel('Average Error'))
        inner_layout.addWidget(self.iter_err_chart)
        self._layout.addWidget(group_box)
示例#8
0
class Main(QWidget):
    def __init__(self):
        super().__init__()

        self.groupBox = QGroupBox("Meniu")
        self.setWindowTitle("Covid-19 duomenys")
        self.setGeometry(300, 300, 500, 400)
        self.setMinimumHeight(500)
        self.setMinimumWidth(400)
        self.setMaximumHeight(500)
        self.setMaximumWidth(400)

        self.GridLayout()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)
        self.setLayout(vbox)
        self.show()

    def GridLayout(self):
        self.groupBox.setFont(QFont("Sanserif", 13))
        gridLayout = QGridLayout()

        button1 = QPushButton("Statistika", self)
        gridLayout.addWidget(button1, 0, 1)
        button1.clicked.connect(self.on_pushButton_clicked)
        self.dialog = Second(self)

        button2 = QPushButton("Įšėjimas", self)
        gridLayout.addWidget(button2, 1, 1)
        button2.clicked.connect(self.exit_app)

        self.groupBox.setLayout(gridLayout)

    def exit_app(self):
        self.close()

    def on_pushButton_clicked(self):
        self.hide()
        self.dialog.show()
    def createPositionIndicationGroup(self):
        self.currentPositionLineEdit = createReadOnlyLineEdit("+0.000")
        self.targetPositionLineEdit = createReadOnlyLineEdit("+0.000")
        self.positionErrorLineEdit = createReadOnlyLineEdit("+0.000")

        self.setCurrentPositionAsZeroButton = QPushButton("Set As Zero")        
        self.resetZeroPositionButton = QPushButton("Reset Zero")

        positionInformationLayout = QGridLayout()
        positionInformationLayout.addWidget(createPositionLabel("Current"), 0, 0)
        positionInformationLayout.addWidget(createPositionLabel("Target"), 0, 1)
        positionInformationLayout.addWidget(createPositionLabel("Error"), 0, 2)
        positionInformationLayout.addWidget(self.currentPositionLineEdit, 1, 0)
        positionInformationLayout.addWidget(self.targetPositionLineEdit, 1, 1)
        positionInformationLayout.addWidget(self.positionErrorLineEdit, 1, 2)
        positionInformationLayout.addWidget(self.setCurrentPositionAsZeroButton, 2, 0)
        positionInformationLayout.addWidget(self.resetZeroPositionButton, 3, 0)

        positionGroupBox = QGroupBox("Azimuth")
        positionGroupBox.setLayout(positionInformationLayout)

        return positionGroupBox
示例#10
0
    def _create_single_parameter_selection(self):
        self._modeler: MultiParameterModeler

        group = QGroupBox('Single-parameter modeler')
        g_layout = QVBoxLayout()
        g_layout.setContentsMargins(0, 0, 0, 0)
        modeler_selection = QComboBox()

        def selection_changed():
            modeler = modeler_selection.currentData()
            self._modeler.single_parameter_modeler = modeler()
            options = ModelerOptionsWidget(
                self,
                self._modeler.single_parameter_modeler,
                has_parent_options=True)
            g_layout.replaceWidget(self._single_parameter_modeler_widget,
                                   options)
            self._single_parameter_modeler_widget.deleteLater()
            self._single_parameter_modeler_widget = options

        for i, (name,
                modeler) in enumerate(single_parameter.all_modelers.items()):
            modeler_selection.addItem(name, modeler)
            modeler_selection.setItemData(i, modeler.DESCRIPTION,
                                          Qt.ToolTipRole)
            if isinstance(self._modeler.single_parameter_modeler, modeler):
                modeler_selection.setCurrentText(name)
        modeler_selection.currentIndexChanged.connect(selection_changed)

        self._single_parameter_modeler_widget = ModelerOptionsWidget(
            self,
            self._modeler.single_parameter_modeler,
            has_parent_options=True)

        g_layout.addWidget(modeler_selection)
        g_layout.addWidget(self._single_parameter_modeler_widget)
        g_layout.addStrut(1)
        group.setLayout(g_layout)
        return group
class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("sttting icon")
        self.setGeometry(300, 300, 500, 400)
        self.setIcon()
        # showing a hint, or tooltip
        self.setToolTip("this is window")

        self.createLayout()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)
        self.setLayout(vbox)
        self.show()

    def setIcon(self):
        appIcon = QIcon("Screenshot from 2019-10-15 09-33-25.png")
        self.setWindowIcon(appIcon)

    def createLayout(self):
        self.groupBox = QGroupBox("please choose ine languages")
        self.groupBox.setFont(QFont("Sanserif", 13))
        hbox = QHBoxLayout()

        button = QPushButton("CSS", self)
        button.setIcon(QIcon("Screenshot from 2019-10-15 09-33-25.png"))
        button.setMinimumHeight(40)
        hbox.addWidget(button)

        button1 = QPushButton("C++", self)
        button1.setIcon(QIcon("Screenshot from 2019-10-15 09-33-25.png"))
        button1.setMinimumHeight(40)
        hbox.addWidget(button1)

        button2 = QPushButton("Python", self)
        button2.setIcon(QIcon("Screenshot from 2019-10-15 09-33-25.png"))
        button2.setMinimumHeight(40)
        hbox.addWidget(button2)
        self.groupBox.setLayout(hbox)
示例#12
0
    def _gui(self):
        layout = QVBoxLayout()
        self.setLayout(layout)

        group = QGroupBox('Other', self)
        group.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        layout.addWidget(group)

        layout = QVBoxLayout()
        group.setLayout(layout)

        problems = List(self)
        problems.problem_selected.connect(self.problem_selected)
        problems.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        layout.addWidget(problems, 0)

        for i in PROBLEMS:
            problems.addItem(i)

        problems.clearSelection()
        layout.setSizeConstraint(QVBoxLayout.SetMinimumSize)
        layout.update()
示例#13
0
文件: chrono.py 项目: Almazys/chrono
    def createNotificationPopup(self):
        popup = QDialog(self)
        popup.setFixedSize(popup.sizeHint().height(), popup.sizeHint().width())
        popup.setWindowTitle("Évènements")
        innerLayout = QVBoxLayout()

        GroupBox = QGroupBox("Activer les notifications")
        GroupBox.setCheckable(True)
        GroupBox.setChecked(self.notification)

        checkBox_popup = QCheckBox("Afficher une popup")
        checkBox_notification = QCheckBox("Afficher une notification")
        checkBox_sound = QCheckBox("Jouer un son")

        if self.notification_popup:
            checkBox_popup.setCheckState(Qt.Checked)
        if self.notification_tray:
            checkBox_notification.setCheckState(Qt.Checked)
        if self.notification_sound:
            checkBox_sound.setCheckState(Qt.Checked)

        innerLayout.addWidget(checkBox_popup)
        innerLayout.addWidget(checkBox_notification)
        innerLayout.addWidget(checkBox_sound)
        innerLayout.addStretch(1)
        GroupBox.setLayout(innerLayout)

        button = QPushButton("Ok")
        button.clicked.connect(lambda: self.changeNotificationSettings(
            popup, GroupBox, checkBox_popup, checkBox_notification,
            checkBox_sound))

        outerLayout = QVBoxLayout()
        outerLayout.addWidget(GroupBox)
        outerLayout.addWidget(button)
        popup.setLayout(outerLayout)

        popup.exec_()
示例#14
0
    def _init_widgets(self):

        # status
        status_box = QGroupBox(self)
        status_box.setTitle("Status")

        self._status_table = QStatusTable(self._controller)
        self._status_table.status = "ready"

        status_layout = QVBoxLayout()
        status_layout.addWidget(self._status_table)

        status_box.setLayout(status_layout)

        # table

        self._team_table = QTeamTable(self._controller)
        team_box = QGroupBox(self)
        team_box.setTitle("Team")

        # operations

        # pull function button
        pullfunc_btn = QPushButton(self)
        pullfunc_btn.setText("Pull func")
        pullfunc_btn.setToolTip("Pull current function from the selected user")
        pullfunc_btn.clicked.connect(self._on_pullfunc_clicked)

        # push function button
        pushfunc_btn = QPushButton()
        pushfunc_btn.setText('Push func')
        pushfunc_btn.setToolTip("Push current function to the repo")
        pushfunc_btn.clicked.connect(self._on_pushfunc_clicked)

        # pull patches button
        pullpatches_btn = QPushButton(self)
        pullpatches_btn.setText("Pull patches")
        pullpatches_btn.setToolTip("Pull all patches from the selected user")
        pullpatches_btn.clicked.connect(self._on_pullpatches_clicked)

        actions_box = QGroupBox(self)
        actions_box.setTitle("Actions")
        actions_layout = QHBoxLayout()
        actions_layout.addWidget(pullfunc_btn)
        actions_layout.addWidget(pushfunc_btn)
        actions_layout.addWidget(pullpatches_btn)
        actions_box.setLayout(actions_layout)

        team_layout = QVBoxLayout()
        team_layout.addWidget(self._team_table)
        team_layout.addWidget(actions_box)
        team_box.setLayout(team_layout)

        main_layout = QVBoxLayout()
        main_layout.addWidget(status_box)
        main_layout.addWidget(team_box)

        self.setLayout(main_layout)
    def updateLayout(self, debriefing):
        updateBox = QGroupBox("Mission status")
        updateLayout = QGridLayout()
        updateBox.setLayout(updateLayout)
        self.debriefing = debriefing

        updateLayout.addWidget(QLabel("<b>Aircraft destroyed</b>"), 0, 0)
        updateLayout.addWidget(QLabel(str(len(debriefing.killed_aircrafts))),
                               0, 1)

        updateLayout.addWidget(QLabel("<b>Ground units destroyed</b>"), 1, 0)
        updateLayout.addWidget(
            QLabel(str(len(debriefing.killed_ground_units))), 1, 1)

        #updateLayout.addWidget(QLabel("<b>Weapons fired</b>"), 2, 0)
        #updateLayout.addWidget(QLabel(str(len(debriefing.weapons_fired))), 2, 1)

        updateLayout.addWidget(QLabel("<b>Base Capture Events</b>"), 2, 0)
        updateLayout.addWidget(
            QLabel(str(len(debriefing.base_capture_events))), 2, 1)

        # Clear previous content of the window
        for i in reversed(range(self.gridLayout.count())):
            try:
                self.gridLayout.itemAt(i).widget().setParent(None)
            except:
                pass

        # Set new window content
        self.gridLayout.addWidget(updateBox, 0, 0)

        if not debriefing.mission_ended:
            self.gridLayout.addWidget(QLabel("<b>Mission is being played</b>"),
                                      1, 0)
            self.gridLayout.addWidget(self.actions, 2, 0)
        else:
            self.gridLayout.addWidget(QLabel("<b>Mission is over</b>"), 1, 0)
            self.gridLayout.addWidget(self.actions2, 2, 0)
示例#16
0
    def createTurnTableControlGroup(self):
        self.gotoPositionSpinBox = createDoubleSpinBox() 
        self.stepSizeSpinBox = createDoubleSpinBox()

        self.goPushButton = QPushButton("Go")
        self.goPushButton.setEnabled(False)
        self.goPushButton.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_G))

        self.stepPushButton = QPushButton("Step")
        self.stepPushButton.setEnabled(False)
        self.stepPushButton.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_S))

        self.enableSteppingCheckBox = QCheckBox("Enable Stepping")
        self.enableSteppingCheckBox.setEnabled(False)
        self.enableSteppingCheckBox.clicked.connect(self.stepPushButton.setEnabled)

        self.stopPushButton = QPushButton("STOP")
        self.stopPushButton.setEnabled(False)
        self.stopPushButton.pressed.connect(lambda: self.motorVoltageSlider.setValue(0.000))
        self.stopPushButton.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_T))

        turnTableVoltageControlGroup = self.createTurnTableVoltageControlGroup()

        turnTableControlGridLayout = QGridLayout()
        turnTableControlGridLayout.addWidget(QLabel("Go To Position:"), 0, 0)
        turnTableControlGridLayout.addWidget(self.gotoPositionSpinBox, 0, 1)
        turnTableControlGridLayout.addWidget(self.goPushButton, 0, 2)
        turnTableControlGridLayout.addWidget(QLabel("Step Size:"), 1, 0)
        turnTableControlGridLayout.addWidget(self.stepSizeSpinBox, 1, 1)
        turnTableControlGridLayout.addWidget(self.stepPushButton, 1, 2)
        turnTableControlGridLayout.addWidget(self.enableSteppingCheckBox, 1, 3)
        turnTableControlGridLayout.addWidget(self.stopPushButton, 2, 3)
        turnTableControlGridLayout.addWidget(turnTableVoltageControlGroup, 3, 0, 3, 4)

        turnTableGroupBox = QGroupBox("Turn Table Controls")
        turnTableGroupBox.setLayout(turnTableControlGridLayout)

        return turnTableGroupBox
示例#17
0
    def init_ui(self):
        layout = QVBoxLayout()

        intel = QGroupBox("Intel")
        intelLayout = QVBoxLayout()

        units = {
            CAP: db.find_unittype(CAP, self.game.enemy_name),
            Embarking: db.find_unittype(Embarking, self.game.enemy_name),
            CAS: db.find_unittype(CAS, self.game.enemy_name),
            PinpointStrike: db.find_unittype(PinpointStrike, self.game.enemy_name),
        }

        for task_type in units.keys():
            units_column = list(set(units[task_type]))

            if sum([self.cp.base.total_units_of_type(u) for u in units_column]) > 0:

                group = QGroupBox(db.task_name(task_type))
                groupLayout = QGridLayout()
                group.setLayout(groupLayout)

                row = 0
                for unit_type in units_column:
                    existing_units = self.cp.base.total_units_of_type(unit_type)
                    if existing_units == 0:
                        continue
                    groupLayout.addWidget(QLabel("<b>" + db.unit_type_name(unit_type) + "</b>"), row, 0)
                    groupLayout.addWidget(QLabel(str(existing_units)), row, 1)
                    row += 1

                intelLayout.addWidget(group)

        intelLayout.addStretch()
        intel.setLayout(intelLayout)
        layout.addWidget(intel)
        layout.addStretch()
        self.setLayout(layout)
示例#18
0
class Window(QWidget):
    def __init__(self):
        super(Window, self).__init__()

        self.setWindowTitle("Pyside2 Simple Application")
        self.setGeometry(300, 300, 500, 500)
        self.createLayout()
        vbox = QVBoxLayout()
        vbox.addWidget(self.groupBox)
        self.setLayout(vbox)

    def createLayout(self):
        self.groupBox = QGroupBox("Please Choose One Language  ")
        self.groupBox.setFont(QFont("Sanserif", 13))
        hbox = QHBoxLayout()
        button1 = QPushButton("CSS", self)
        hbox.addWidget(button1)
        button2 = QPushButton("C++", self)
        hbox.addWidget(button2)
        button3 = QPushButton("Java", self)
        hbox.addWidget(button3)

        self.groupBox.setLayout(hbox)
    def __create_contact_groupbox(self):
        hbox = QHBoxLayout()
        about_group = QGroupBox('About:')
        self.about = QTextEdit()
        self.about.setReadOnly(True)
        hbox.addWidget(self.about)
        about_group.setLayout(hbox)

        layout = QFormLayout()
        contact_group = QGroupBox('Contact Info')
        self.contact_name = QLabel()
        self.contact_email = QLabel()
        self.contact_website = QPushButton('Apply')
        self.contact_website.clicked.connect(
            lambda: webbrowser.open(self.apply_website))
        layout.addRow(QLabel('Contact:'), self.contact_name)
        layout.addRow(QLabel('Email:'), self.contact_email)
        layout.addRow(QLabel('Website:'), self.contact_website)
        contact_group.setLayout(layout)

        self.contact_layout = QHBoxLayout()
        self.contact_layout.addWidget(about_group, Style.TWO_THIRDS.value)
        self.contact_layout.addWidget(contact_group, Style.ONE_THIRD.value)
示例#20
0
    def __init__(self, tool):
        QWidget.__init__(self)

        self.tool = tool

        self.layout = QBoxLayout(QBoxLayout.TopToBottom)

        self.info_label = QLabel(
            """The system sometimes overrides the power and temperature limits.
The intel-undervolt daemon can be used to enforce them periodically.
Enabling the systemd service enables you to apply your settings on boot.""")
        self.info_label.setWordWrap(True)
        self.layout.addWidget(self.info_label)

        self.layout.addWidget(DaemonIntervalControls(self.tool))

        systemd_group = QGroupBox("systemd service")
        self.systemd_controls = SystemdControls(self.tool)
        systemd_group.setLayout(self.systemd_controls.layout)
        systemd_group.setEnabled(self.tool.has_systemd)
        self.layout.addWidget(systemd_group)

        self.setLayout(self.layout)
示例#21
0
    def set_information(self):
        group = QGroupBox("Information")
        grid = QGridLayout()
        group.setLayout(grid)
        group.setFixedSize(200, 130)

        start_t = QLabel("Experiment Start Time: ")
        grid.addWidget(start_t, 0, 0)

        start_v = QLabel("NA")
        grid.addWidget(start_v, 0, 2)

        block_n = QLabel("Block Number: ")
        grid.addWidget(block_n, 1, 0)

        block_v = QLabel("NA")
        grid.addWidget(block_v, 1, 2)

        spacer = QSpacerItem(100, 200, QSizePolicy.Minimum,
                             QSizePolicy.Expanding)
        grid.addItem(spacer, 2, 1)

        return group
示例#22
0
    def __init__(self):
        super().__init__()

        self.label1 = QLabel('Describe the picture: ')
        self.line_edit = QLineEdit(self)
        #print(self.line_edit.QLineEdit.text())
        preprocess(image_info)
        self.btn = QPushButton("Search")
        self.btn.clicked.connect(self.on_click)

        hbox1 = QHBoxLayout()
        hbox1.addWidget(self.label1)
        hbox1.addWidget(self.line_edit)
        hbox1.addWidget(self.btn)

        gbox1 = QGroupBox()
        gbox1.setLayout(hbox1)

        mbox = QVBoxLayout()
        mbox.addWidget(gbox1)

        self.setLayout(mbox)
        self.setWindowTitle("CST 205 HW3")
    def init_ui(self):
        layout = QVBoxLayout()

        wpt_layout = QHBoxLayout()
        wpt_layout.addWidget(QLabel("Target : "))
        wpt_layout.addStretch()
        wpt_layout.addWidget(self.tgt_selection_box, alignment=Qt.AlignRight)

        distToTargetBox = QGroupBox("Infos :")
        distToTarget = QHBoxLayout()
        distToTarget.addWidget(QLabel("Distance to target : "))
        distToTarget.addStretch()
        distToTarget.addWidget(self.distanceToTargetLabel,
                               alignment=Qt.AlignRight)
        distToTargetBox.setLayout(distToTarget)

        layout.addLayout(wpt_layout)
        layout.addWidget(self.strike_infos)
        layout.addWidget(distToTargetBox)
        layout.addStretch()
        layout.addWidget(self.ok_button)

        self.setLayout(layout)
示例#24
0
    def __init__(self,logger:Logger=None,layout:QGridLayout=None,session:ScriptSession=None,templates:Image=None): 
        super().__init__(logger,layout,session,templates)
        # Initialize scripts and layout here

        ### Example groupbox_1
        groupbox_1 = QGroupBox('Description')
        label1 = QLabel('Example')
        layout_1 = QVBoxLayout()
        layout_1.addWidget(label1)
        groupbox_1.setLayout(layout_1)

        ### Example groupbox_2
        groupbox_2 = QGroupBox('Controls')
        button1 = QPushButton('test')
        layout_2 = QVBoxLayout()
        layout_2.addWidget(button1)
        groupbox_2.setLayout(layout_2)

        self.layout.addWidget(groupbox_1,0,0,-1,1)
        self.layout.addWidget(groupbox_2,0,1,-1,1)
        button1.pressed.connect(self._onClickButton) # you can connect signals

        self.logger.info('example: __init__ is loaded')
示例#25
0
    def __init__(self):
        super().__init__()

        menuBar = self.menuBar()
        menuBar.addMenu(self.createFileMenu())
        menuBar.addMenu(self.createSettingsMenu())
        menuBar.addMenu(self.createHelpMenu())

        self.statusBar().showMessage("Ready")

        connectionStatusGroupBox = self.createConnectionStatusGroup()
        positionIndicationGroupBox = self.createPositionIndicationGroup()
        turnTableControlGroupBox = self.createTurnTableControlGroup()

        mainWidgetLayout = QVBoxLayout()
        mainWidgetLayout.addWidget(connectionStatusGroupBox)
        mainWidgetLayout.addWidget(positionIndicationGroupBox)
        mainWidgetLayout.addWidget(turnTableControlGroupBox)

        mainWidgetGroup = QGroupBox()
        mainWidgetGroup.setLayout(mainWidgetLayout)

        self.setCentralWidget(mainWidgetGroup)
示例#26
0
    def createChoiceBox(self):
        #生成顯示玩家&電腦出拳的畫面
        self.h_layout = QHBoxLayout()

        box_font = QFont()
        box_font.setPointSize(16)

        choice_label_font = QFont()
        choice_label_font.setPointSize(80)

        #產生顯示玩家選擇的畫面,並使用 QGroupBox & QHBoxLayout 排版
        player_groupbox = QGroupBox("玩家")
        player_groupbox.setFont(box_font)

        self.player_choice_label = QLabel(self.paper)
        self.player_choice_label.setFixedSize(120, 150)
        self.player_choice_label.setFont(choice_label_font)

        player_layout = QHBoxLayout()
        player_layout.addWidget(self.player_choice_label)
        player_groupbox.setLayout(player_layout)

        # 產生顯示電腦選擇的畫面,並使用 QGroupBox & QHBoxLayout 排版
        com_groupbox = QGroupBox("電腦")
        com_groupbox.setFont(box_font)

        self.com_choice_label = QLabel(self.paper)
        self.com_choice_label.setFixedSize(120, 150)
        self.com_choice_label.setFont(choice_label_font)

        com_layout = QHBoxLayout()
        com_layout.addWidget(self.com_choice_label)
        com_groupbox.setLayout(com_layout)

        #將玩家&電腦的畫面用 GHBoxLayout 排版
        self.h_layout.addWidget(player_groupbox)
        self.h_layout.addWidget(com_groupbox)
示例#27
0
    def create_project_section(self):
        gbox_active_project = QGroupBox('Project')

        lbl_project_name = QLabel('Name:')
        self.lbl_project_name_value = QLabel('')

        lbl_elapsed_time = QLabel('Elapsed Time:')
        self.lbl_elapsed_time_value = QLabel('')

        lbl_remaining_time = QLabel('Remaining time:')
        self.lbl_remaining_time_value = QLabel('')

        lbl_step = QLabel('Current Step:')
        self.lbl_step_value = QLabel('')

        self.pbar_completion = QProgressBar()
        self.pbar_completion.setValue(0)

        # organise the fields in a grid
        layout = QGridLayout()
        layout.addWidget(lbl_project_name, 0, 0, Qt.AlignRight)
        layout.addWidget(self.lbl_project_name_value, 0, 1, 1, 3, Qt.AlignLeft)
        layout.addWidget(lbl_elapsed_time, 1, 0, Qt.AlignRight)
        layout.addWidget(self.lbl_elapsed_time_value, 1, 1, 1, 3, Qt.AlignLeft)
        layout.addWidget(lbl_remaining_time, 2, 0, Qt.AlignRight)
        layout.addWidget(self.lbl_remaining_time_value, 2, 1, 1, 3, Qt.AlignLeft)
        layout.addWidget(lbl_step, 3, 0,Qt.AlignRight)
        layout.addWidget(self.lbl_step_value, 3, 1, 1, 3, Qt.AlignLeft)
        layout.setRowStretch(5, 40)
        layout.addWidget(self.pbar_completion, 6, 0, 1, 4, Qt.AlignCenter)

        self.pbar_completion.setMinimumWidth(gbox_active_project.width() - 200)

        gbox_active_project.setLayout(layout)

        return gbox_active_project
示例#28
0
    def initUI(self):
        self.listWidget = QListWidget()
        self.initDevices()

        self.treeWidget = QTreeWidget()
        self.treeWidget.itemPressed.connect(self.onItemPressed)
        self.treeWidget.setColumnCount(4)
        self.treeWidget.setColumnWidth(0, 250)
        self.treeWidget.setColumnWidth(1, 300)
        self.treeWidget.setColumnWidth(2, 300)
        self.treeWidget.setColumnWidth(3, 150)
        self.treeWidget.setHeaderLabels(["Service", "Service UUID", "Characteristic UUID", "Characteristic Property"])

        btn = QPushButton("Read Services")
        btn.clicked.connect(self.onPushButton)

        groupDevices = QGroupBox("Devices")
        groupDevices.setMaximumWidth(300)

        vbox = QVBoxLayout()
        vbox.addWidget(self.listWidget)
        vbox.addWidget(btn)
        groupDevices.setLayout(vbox)

        self.btnR = QPushButton("Read")
        self.btnR.clicked.connect(self.onReadButton)
        self.btnW = QPushButton("Write")
        self.btnW.clicked.connect(self.onWriteButton)
        self.lneI = QLineEdit()
        self.chkN = QCheckBox("Notify")
        self.chkN.toggled.connect(self.onNotifyCheck)
        hbox = QHBoxLayout()
        hbox.addWidget(self.btnR)
        hbox.addWidget(self.btnW)
        hbox.addWidget(self.lneI)
        hbox.addWidget(self.chkN)

        groupProperty = QGroupBox("Property")
        #groupProperty.setLayout(vbox)
        groupProperty.setLayout(hbox)

        groupServices = QGroupBox("Services")

        vbox = QVBoxLayout()
        vbox.addWidget(self.treeWidget)
        vbox.addWidget(groupProperty)
        groupServices.setLayout(vbox)

        hbox = QHBoxLayout()
        hbox.addWidget(groupDevices)
        hbox.addWidget(groupServices)
        self.setLayout(hbox)
        
        self.setGeometry(300, 300, 800, 600)
        self.setWindowTitle('BLE Discover')
        self.show()
示例#29
0
    def make_func_groupbox(self):
        func_layout = QHBoxLayout()

        self.encode_widget = RadioBox(encode_dict)
        encode_layout = self.encode_widget.make_radio_box("UTF-8 with BOM")
        self.encode_groupbox = QGroupBox("Encode to: ")
        self.encode_groupbox.setLayout(encode_layout)
        self.encode_groupbox.setCheckable(True)
        self.encode_groupbox.clicked.connect(self.option_set)
        func_layout.addWidget(self.encode_groupbox)

        self.fmt_groupbox = QGroupBox("Convert image format")
        fmt_hbox = QHBoxLayout()
        self.format_widget_from = RadioBox(self.format_dict)
        format_layout_from = self.format_widget_from.make_radio_box("WebP")
        fmt_from_groupbox = QGroupBox("Convert image from: ")
        fmt_from_groupbox.setLayout(format_layout_from)
        fmt_hbox.addWidget(fmt_from_groupbox)

        self.format_widget_to = RadioBox(self.format_dict)
        format_layout_to = self.format_widget_to.make_radio_box("PNG")
        fmt_to_groupbox = QGroupBox("Convert image to: ")
        fmt_to_groupbox.setLayout(format_layout_to)
        fmt_hbox.addWidget(fmt_to_groupbox)
        self.fmt_groupbox.setLayout(fmt_hbox)
        self.fmt_groupbox.setCheckable(True)
        func_layout.addWidget(self.fmt_groupbox)

        option_groupbox = QGroupBox("OPTION: ")
        option_layout = QVBoxLayout()
        self.change_txt_yn = QCheckBox("Change image ext in CSV/ERB", self)
        self.change_txt_yn.toggle()
        self.change_txt_yn.clicked.connect(self.option_set)
        self.backup_yn = QCheckBox("Place files in Result directory", self)
        self.backup_yn.clicked.connect(self.option_set)

        option_layout.addWidget(self.change_txt_yn)
        option_layout.addWidget(self.backup_yn)
        option_groupbox.setLayout(option_layout)
        func_layout.addWidget(option_groupbox)

        self.main_layout.addLayout(func_layout)
示例#30
0
class MonteCarloTab(NewAnalysisTab):
    def __init__(self, parent=None):
        super(MonteCarloTab, self).__init__(parent)
        self.parent: LCAResultsSubTab = parent

        self.layout.addLayout(get_header_layout('Monte Carlo Simulation'))
        self.scenario_label = QLabel("Scenario:")
        self.include_box = QGroupBox("Include uncertainty for:", self)
        grid = QGridLayout()
        self.include_tech = QCheckBox("Technosphere", self)
        self.include_tech.setChecked(True)
        self.include_bio = QCheckBox("Biosphere", self)
        self.include_bio.setChecked(True)
        self.include_cf = QCheckBox("Characterization Factors", self)
        self.include_cf.setChecked(True)
        self.include_parameters = QCheckBox("Parameters", self)
        self.include_parameters.setChecked(True)
        grid.addWidget(self.include_tech, 0, 0)
        grid.addWidget(self.include_bio, 0, 1)
        grid.addWidget(self.include_cf, 1, 0)
        grid.addWidget(self.include_parameters, 1, 1)
        self.include_box.setLayout(grid)

        self.add_MC_ui_elements()

        self.table = LCAResultsTable()
        self.table.table_name = 'MonteCarlo_' + self.parent.cs_name
        self.plot = MonteCarloPlot(self.parent)
        self.plot.hide()
        self.plot.plot_name = 'MonteCarlo_' + self.parent.cs_name
        self.layout.addWidget(self.plot)
        self.export_widget = self.build_export(has_plot=True, has_table=True)
        self.layout.addWidget(self.export_widget)
        self.layout.setAlignment(QtCore.Qt.AlignTop)
        self.connect_signals()

    def connect_signals(self):
        self.button_run.clicked.connect(self.calculate_mc_lca)
        # signals.monte_carlo_ready.connect(self.update_mc)
        # self.combobox_fu.currentIndexChanged.connect(self.update_plot)
        self.combobox_methods.currentIndexChanged.connect(
            # ignore the index and send the cs_name instead
            lambda x: self.update_mc(cs_name=self.parent.cs_name))

        # signals
        # self.radio_button_biosphere.clicked.connect(self.button_clicked)
        # self.radio_button_technosphere.clicked.connect(self.button_clicked)

        if self.using_presamples:
            self.scenario_box.currentIndexChanged.connect(
                self.parent.update_scenario_data)
            self.parent.update_scenario_box_index.connect(
                lambda index: self.set_combobox_index(self.scenario_box, index
                                                      ))

    def add_MC_ui_elements(self):
        layout_mc = QVBoxLayout()

        # H-LAYOUT start simulation
        self.button_run = QPushButton('Run Simulation')
        self.label_iterations = QLabel('Iterations:')
        self.iterations = QLineEdit('10')
        self.iterations.setFixedWidth(40)
        self.iterations.setValidator(QtGui.QIntValidator(1, 1000))
        self.label_seed = QLabel('Random seed:')
        self.label_seed.setToolTip(
            'Seed value (integer) for the random number generator. '
            'Use this for reproducible samples.')
        self.seed = QLineEdit('')
        self.seed.setFixedWidth(30)

        self.hlayout_run = QHBoxLayout()
        self.hlayout_run.addWidget(self.scenario_label)
        self.hlayout_run.addWidget(self.scenario_box)
        self.hlayout_run.addWidget(self.button_run)
        self.hlayout_run.addWidget(self.label_iterations)
        self.hlayout_run.addWidget(self.iterations)
        self.hlayout_run.addWidget(self.label_seed)
        self.hlayout_run.addWidget(self.seed)
        self.hlayout_run.addWidget(self.include_box)
        self.hlayout_run.addStretch(1)
        layout_mc.addLayout(self.hlayout_run)

        # self.label_running = QLabel('Running a Monte Carlo simulation. Please allow some time for this. '
        #                             'Please do not run another simulation at the same time.')
        # self.layout_mc.addWidget(self.label_running)
        # self.label_running.hide()

        # # buttons for all FUs or for all methods
        # self.radio_button_all_fu = QRadioButton("For all functional units")
        # self.radio_button_all_methods = QRadioButton("Technosphere flows")
        #
        # self.radio_button_biosphere.setChecked(True)
        # self.radio_button_technosphere.setChecked(False)
        #
        # self.label_for_all_fu = QLabel('For all functional units')
        # self.combobox_fu = QRadioButton()
        # self.hlayout_fu = QHBoxLayout()

        # FU selection
        # self.label_fu = QLabel('Choose functional unit')
        # self.combobox_fu = QComboBox()
        # self.hlayout_fu = QHBoxLayout()
        #
        # self.hlayout_fu.addWidget(self.label_fu)
        # self.hlayout_fu.addWidget(self.combobox_fu)
        # self.hlayout_fu.addStretch()
        # self.layout_mc.addLayout(self.hlayout_fu)

        # method selection
        self.method_selection_widget = QWidget()
        self.label_methods = QLabel('Choose LCIA method')
        self.combobox_methods = QComboBox()
        self.hlayout_methods = QHBoxLayout()

        self.hlayout_methods.addWidget(self.label_methods)
        self.hlayout_methods.addWidget(self.combobox_methods)
        self.hlayout_methods.addStretch()
        self.method_selection_widget.setLayout(self.hlayout_methods)

        layout_mc.addWidget(self.method_selection_widget)
        self.method_selection_widget.hide()

        self.layout.addLayout(layout_mc)

    def build_export(self,
                     has_table: bool = True,
                     has_plot: bool = True) -> QWidget:
        """Construct the export layout but set it into a widget because we
         want to hide it."""
        export_layout = super().build_export(has_table, has_plot)
        export_widget = QWidget()
        export_widget.setLayout(export_layout)
        # Hide widget until MC is calculated
        export_widget.hide()
        return export_widget

    @QtCore.Slot(name="calculateMcLca")
    def calculate_mc_lca(self):
        self.method_selection_widget.hide()
        self.plot.hide()
        self.export_widget.hide()

        iterations = int(self.iterations.text())
        seed = None
        if self.seed.text():
            print('SEED: ', self.seed.text())
            try:
                seed = int(self.seed.text())
            except ValueError:
                traceback.print_exc()
                QMessageBox.warning(
                    self, 'Warning',
                    'Seed value must be an integer number or left empty.')
                self.seed.setText('')
                return
        includes = {
            "technosphere": self.include_tech.isChecked(),
            "biosphere": self.include_bio.isChecked(),
            "cf": self.include_cf.isChecked(),
            "parameters": self.include_parameters.isChecked(),
        }

        try:
            self.parent.mc.calculate(iterations=iterations,
                                     seed=seed,
                                     **includes)
            self.update_mc()
        except InvalidParamsError as e:  # This can occur if uncertainty data is missing or otherwise broken
            # print(e)
            traceback.print_exc()
            QMessageBox.warning(self,
                                'Could not perform Monte Carlo simulation',
                                str(e))

        # a threaded way for this - unfortunatley this crashes as:
        # pypardsio_solver is used for the 'spsolve' and 'factorized' functions. Python crashes on windows if multiple
        # instances of PyPardisoSolver make calls to the Pardiso library
        # worker_thread = WorkerThread()
        # print('Created local worker_thread')
        # worker_thread.set_mc(self.parent.mc, iterations=iterations)
        # print('Passed object to thread.')
        # worker_thread.start()
        # self.label_running.show()

        #

        # thread = NewCSMCThread() #self.parent.mc
        # thread.calculation_finished.connect(
        #     lambda x: print('Calculation finished.'))
        # thread.start()

        # # give us a thread and start it
        # thread = QtCore.QThread()
        # thread.start()
        #
        # # create a worker and move it to our extra thread
        # worker = Worker()
        # worker.moveToThread(thread)

        # self.parent.mct.start()
        # self.parent.mct.run(iterations=iterations)
        # self.parent.mct.finished()

        # objThread = QtCore.QThread()
        # obj = QObjectMC()  # self.parent.cs_name
        # obj.moveToThread(objThread)
        # obj.finished.connect(objThread.quit)
        # objThread.started.connect(obj.long_running)
        # # objThread.finished.connect(app.exit)
        # objThread.finished.connect(
        #     lambda x: print('Finished Thread!')
        # )
        # objThread.start()

        # objThread = QtCore.QThread()
        # obj = SomeObject()
        # obj.moveToThread(objThread)
        # obj.finished.connect(objThread.quit)
        # objThread.started.connect(obj.long_running)
        # objThread.finished.connect(
        #     lambda x: print('Finished Thread!')
        # )
        # objThread.start()

        # self.method_selection_widget.show()
        # self.plot.show()
        # self.export_widget.show()

    def configure_scenario(self):
        super().configure_scenario()
        self.scenario_label.setVisible(self.using_presamples)

    def update_tab(self):
        self.update_combobox(self.combobox_methods,
                             [str(m) for m in self.parent.mc.methods])
        # self.update_combobox(self.combobox_methods, [str(m) for m in self.parent.mct.mc.methods])

    def update_mc(self, cs_name=None):
        # act = self.combobox_fu.currentText()
        # activity_index = self.combobox_fu.currentIndex()
        # act_key = self.parent.mc.activity_keys[activity_index]
        # if cs_name != self.parent.cs_name:  # relevant if several CS are open at the same time
        #     return

        # self.label_running.hide()
        self.method_selection_widget.show()
        self.export_widget.show()

        method_index = self.combobox_methods.currentIndex()
        method = self.parent.mc.methods[method_index]

        # data = self.parent.mc.get_results_by(act_key=act_key, method=method)
        self.df = self.parent.mc.get_results_dataframe(method=method)

        self.update_table()
        self.update_plot(method=method)
        filename = '_'.join([
            str(x)
            for x in [self.parent.cs_name, 'Monte Carlo results',
                      str(method)]
        ])
        self.plot.plot_name, self.table.table_name = filename, filename

    def update_plot(self, method):
        idx = self.layout.indexOf(self.plot)
        self.plot.figure.clf()
        self.plot.deleteLater()
        self.plot = MonteCarloPlot(self.parent)
        self.layout.insertWidget(idx, self.plot)
        self.plot.plot(self.df, method=method)
        self.plot.show()
        if self.layout.parentWidget():
            self.layout.parentWidget().updateGeometry()

    def update_table(self):
        self.table.sync(self.df)
示例#31
0
class Dialog(QDialog):
    def __init__(self):
        super(Dialog, self).__init__()

        self.rotableWidgets = []

        self.createRotableGroupBox()
        self.createOptionsGroupBox()
        self.createButtonBox()

        mainLayout = QGridLayout()
        mainLayout.addWidget(self.rotableGroupBox, 0, 0)
        mainLayout.addWidget(self.optionsGroupBox, 1, 0)
        mainLayout.addWidget(self.buttonBox, 2, 0)
        mainLayout.setSizeConstraint(QLayout.SetMinimumSize)

        self.mainLayout = mainLayout
        self.setLayout(self.mainLayout)

        self.setWindowTitle("Dynamic Layouts")

    def rotateWidgets(self):
        count = len(self.rotableWidgets)
        if count % 2 == 1:
            raise AssertionError("Number of widgets must be even")

        for widget in self.rotableWidgets:
            self.rotableLayout.removeWidget(widget)

        self.rotableWidgets.append(self.rotableWidgets.pop(0))

        for i in range(count//2):
            self.rotableLayout.addWidget(self.rotableWidgets[count - i - 1], 0, i)
            self.rotableLayout.addWidget(self.rotableWidgets[i], 1, i)


    def buttonsOrientationChanged(self, index):
        self.mainLayout.setSizeConstraint(QLayout.SetNoConstraint)
        self.setMinimumSize(0, 0)

        orientation = Qt.Orientation(int(self.buttonsOrientationComboBox.itemData(index)))

        if orientation == self.buttonBox.orientation():
            return

        self.mainLayout.removeWidget(self.buttonBox)

        spacing = self.mainLayout.spacing()

        oldSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing)
        self.buttonBox.setOrientation(orientation)
        newSizeHint = self.buttonBox.sizeHint() + QSize(spacing, spacing)

        if orientation == Qt.Horizontal:
            self.mainLayout.addWidget(self.buttonBox, 2, 0)
            self.resize(self.size() + QSize(-oldSizeHint.width(), newSizeHint.height()))
        else:
            self.mainLayout.addWidget(self.buttonBox, 0, 3, 2, 1)
            self.resize(self.size() + QSize(newSizeHint.width(), -oldSizeHint.height()))

        self.mainLayout.setSizeConstraint(QLayout.SetDefaultConstraint)

    def show_help(self):
        QMessageBox.information(self, "Dynamic Layouts Help",
                            "This example shows how to change layouts "
                            "dynamically.")

    def createRotableGroupBox(self):
        self.rotableGroupBox = QGroupBox("Rotable Widgets")

        self.rotableWidgets.append(QSpinBox())
        self.rotableWidgets.append(QSlider())
        self.rotableWidgets.append(QDial())
        self.rotableWidgets.append(QProgressBar())
        count = len(self.rotableWidgets)
        for i in range(count):
            self.rotableWidgets[i].valueChanged[int].\
                connect(self.rotableWidgets[(i+1) % count].setValue)

        self.rotableLayout = QGridLayout()
        self.rotableGroupBox.setLayout(self.rotableLayout)

        self.rotateWidgets()

    def createOptionsGroupBox(self):
        self.optionsGroupBox = QGroupBox("Options")

        buttonsOrientationLabel = QLabel("Orientation of buttons:")

        buttonsOrientationComboBox = QComboBox()
        buttonsOrientationComboBox.addItem("Horizontal", Qt.Horizontal)
        buttonsOrientationComboBox.addItem("Vertical", Qt.Vertical)
        buttonsOrientationComboBox.currentIndexChanged[int].connect(self.buttonsOrientationChanged)

        self.buttonsOrientationComboBox = buttonsOrientationComboBox

        optionsLayout = QGridLayout()
        optionsLayout.addWidget(buttonsOrientationLabel, 0, 0)
        optionsLayout.addWidget(self.buttonsOrientationComboBox, 0, 1)
        optionsLayout.setColumnStretch(2, 1)
        self.optionsGroupBox.setLayout(optionsLayout)

    def createButtonBox(self):
        self.buttonBox = QDialogButtonBox()

        closeButton = self.buttonBox.addButton(QDialogButtonBox.Close)
        helpButton = self.buttonBox.addButton(QDialogButtonBox.Help)
        rotateWidgetsButton = self.buttonBox.addButton("Rotate &Widgets", QDialogButtonBox.ActionRole)

        rotateWidgetsButton.clicked.connect(self.rotateWidgets)
        closeButton.clicked.connect(self.close)
        helpButton.clicked.connect(self.show_help)
示例#32
0
class ToolBox(QVBoxLayout):

    sig = QtCore.Signal(object)
    listThread = None
    groupBoxThreadInfo = None
    threadvbox = None
    mode = None

    def __init__(self, mode, parentQWidget = None):
        QVBoxLayout.__init__(self)

        self.sig.connect(self.addThreadList)
        self.mode = mode

        self.sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)

        self.groupBoxSearch = QGroupBox()
        self.groupBoxSearch.setStyleSheet("QGroupBox {border: 1px solid gray; border-radius: 4px; };")
        vboxSearch = QVBoxLayout()
        self.searchTitle = QLabel("Search Messages")
        vboxSearch.addWidget(self.searchTitle)
        self.searchHLayout = QHBoxLayout()
        self.editTextSearch = QTextEdit('')
        self.editTextSearch.setFixedSize(200,30)
        self.buttonSearch = QPushButton('Search')
        self.buttonSearch.setFixedSize(100,30)
        self.buttonSearch.clicked.connect(self.searchMsg)
        vboxSearch.addWidget(self.editTextSearch)
        self.searchHLayout.addWidget(self.buttonSearch)
        self.searchCursor = QLabel()
        self.searchHLayout.addWidget(self.searchCursor)
        vboxSearch.addLayout(self.searchHLayout)
        self.browseHLayout = QHBoxLayout()
        self.buttonLookUp = QPushButton('\u21e7')  #Arrow up
        self.buttonLookUp.setFixedWidth(100)
        self.buttonLookUp.clicked.connect(self.moveToPrev)
        self.buttonLookDown = QPushButton('\u21e9') #Arrow down
        self.buttonLookDown.setFixedWidth(100)
        self.buttonLookDown.clicked.connect(self.moveToNext)
        self.browseHLayout.addWidget(self.buttonLookUp)
        self.browseHLayout.addWidget(self.buttonLookDown)
        vboxSearch.addLayout(self.browseHLayout)
        self.groupBoxSearch.setLayout(vboxSearch)
        self.addWidget(self.groupBoxSearch)
        self.groupBoxSearch.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))

        self.buttonHiddenLifelines = QPushButton('Show hidden life-lines')
        self.buttonHiddenLifelines.setFixedWidth(200)
        self.buttonHiddenLifelines.clicked.connect(self.showHiddenLifelines)
        self.addWidget(self.buttonHiddenLifelines)

        self.buttonHiddenMessages = QPushButton('Show hidden Messages')
        self.buttonHiddenMessages.setFixedWidth(200)
        self.buttonHiddenMessages.clicked.connect(self.showHiddenMessages)
        self.addWidget(self.buttonHiddenMessages)

        if const.mode_interactive == mode:
            self.buttonCapture = QPushButton('Capture')
            self.buttonCapture.setFixedWidth(200)
            self.buttonCapture.clicked.connect(self.notifyCapture)
            self.addWidget(self.buttonCapture)
        self.msgRcv = []
        self.msgInfo = QLabel("Message Info.")
        self.groupBoxMessageInfo = QGroupBox()
        self.groupBoxMessageInfo.setStyleSheet("QGroupBox {border: 1px solid gray; border-radius: 9px; margin-top: 0.5em} QGroupBox::title {subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px;")
        vbox = QVBoxLayout()
        vbox.addWidget(self.msgInfo)
        self.tableTime = QTableWidget(3,2)
        self.tableTime.setHorizontalHeaderLabels(['-','time'])
        self.tableTime.setColumnWidth(0,80)
        self.tableTime.setColumnWidth(1,150)
        vwidth = self.tableTime.verticalHeader().length()
        hwidth = self.tableTime.horizontalHeader().height()
        fwidth = self.tableTime.frameWidth() * 2
        self.tableTime.setFixedHeight(vwidth + hwidth + fwidth)
        self.tableTime.horizontalHeader().setStretchLastSection(True)
        self.tableTime.setItem(0,0,QTableWidgetItem('begin'))
        self.tableTime.setItem(0,1,QTableWidgetItem(' - '))
        self.tableTime.setItem(1,0,QTableWidgetItem('end'))
        self.tableTime.setItem(1,1,QTableWidgetItem(' - '))
        self.tableTime.setItem(2,0,QTableWidgetItem('duration'))
        self.tableTime.setItem(2,1,QTableWidgetItem(' - '))
        vbox.addWidget(self.tableTime)

        self.titleArg = QLabel('Argument List')
        vbox.addWidget(self.titleArg)

        max_arg_num = 10
        self.tableArgs = QTableWidget(max_arg_num,2)
        self.tableArgs.setHorizontalHeaderLabels(['type','value'])
        for idx in range(0,max_arg_num):
            self.tableArgs.setItem(idx,0,QTableWidgetItem())
            self.tableArgs.setItem(idx,1,QTableWidgetItem())
        self.tableArgs.horizontalHeader().setStretchLastSection(True)
        vbox.addWidget(self.tableArgs)

        self.titleArg = QLabel('Return Value List')
        vbox.addWidget(self.titleArg)

        max_ret_num = 4
        self.tableRet = QTableWidget(max_ret_num,2)
        self.tableRet.setHorizontalHeaderLabels(['type','value'])
        for idx in range(0,max_ret_num):
            self.tableRet.setItem(idx,0,QTableWidgetItem())
            self.tableRet.setItem(idx,1,QTableWidgetItem())
        self.tableRet.horizontalHeader().setStretchLastSection(True)
        vwidth = self.tableRet.verticalHeader().length()
        hwidth = self.tableRet.horizontalHeader().height()
        fwidth = self.tableRet.frameWidth() * 2
        self.tableRet.setFixedHeight(vwidth + hwidth + fwidth)
        vbox.addWidget(self.tableRet)

        self.buttonSrcView = QPushButton('view code')
        self.buttonSrcView.setFixedWidth(200)
        self.buttonSrcView.clicked.connect(self.openSourceViewer)
        self.buttonHide = QPushButton('Hide')
        self.buttonHide.setFixedWidth(200)
        self.buttonHide.clicked.connect(self.notifyHide)
        self.buttonHideAllMsg = QPushButton('Hide All')
        self.buttonHideAllMsg.setFixedWidth(200)
        self.buttonHideAllMsg.clicked.connect(self.hideAllMsgNamedAsSelected)
        self.groupBoxMessageInfo.setLayout(vbox)
        self.checkHideCircular = QCheckBox('Hide Circular Messages')
        self.checkHideCircular.setCheckState(QtCore.Qt.Unchecked)
        self.checkHideCircular.stateChanged.connect(self.changeHideCircularMessage)
        self.addWidget(self.checkHideCircular)
        self.addWidget(self.groupBoxMessageInfo)
        self.groupBoxMessageInfo.setSizePolicy(self.sizePolicy)

    def reset(self):
        for idx in reversed(range(0,self.listThread.count())):
            self.listThread.takeItem(idx)

    def setMsgInfoMessage(self,msg):
        self.strMessage = msg

    def changeHideCircularMessage(self,state):
        if state == QtCore.Qt.Unchecked:
            self.diagramView.hideCircularChanged(False)
        elif state == QtCore.Qt.Checked:
            self.diagramView.hideCircularChanged(True)
    
    def setMsgInfoModule(self,module):
        self.strModule = module

    def updateSearchStatus(self,curr,number):
        self.searchCursor.setText("%d/%d" % (curr,number))

    def connectSourceViewer(self,viewer):
        self.srcViewer = viewer

    def openSourceViewer(self):
        self.srcViewer.openViewer(self.strModule,self.strMessage)

    def setMessageInfoTime(self,begin,end,duration):
        self.tableTime.item(0,1).setText(begin)
        self.tableTime.item(1,1).setText(end)
        self.tableTime.item(2,1).setText(duration + ' msec')

    def setMessageInfoArg(self,listParam,listArg):
        # Clear the contents in the table
        max_arg_num = 10
        for idx in range(0,max_arg_num):
            self.tableArgs.item(idx,0).setText('')
            self.tableArgs.item(idx,1).setText('')

        if listArg:
            for idx, text in enumerate(listArg):
                self.tableArgs.item(idx,1).setText(text)
            for idx, text in enumerate(listParam):
                self.tableArgs.item(idx,0).setText(text)
        else:
            for idx in range(0,self.tableArgs.rowCount()):
                self.tableArgs.item(idx,1).setText('')
                self.tableArgs.item(idx,0).setText('')

    def setMessageInfoRet(self,listRet):
        if listRet:
            for idx, text in enumerate(listRet):
                self.tableRet.item(idx,1).setText(text)
        else:
            for idx in range(0,self.tableRet.rowCount()):
                self.tableRet.item(idx,1).setText('')
                self.tableRet.item(idx,0).setText('')

    def notifyInteractiveStateChanged(self,state):
        if const.mode_interactive != self.mode:
            return

        if const.STATE_INTERACTIVE_CAPTURING == state:
            self.buttonCapture.setEnabled(True)
            self.buttonCapture.setText('Stop Capture')
        if const.STATE_INTERACTIVE_PROCESSING == state:
            self.buttonCapture.setEnabled(False)
        if const.STATE_INTERACTIVE_IDLE == state:
            self.buttonCapture.setEnabled(True)
            self.buttonCapture.setText('Capture')
        if const.STATE_INTERACTIVE_RESET == state:
            self.buttonCapture.setEnabled(True)
            self.buttonCapture.setText('Capture')
        elif const.STATE_INTERACTIVE_ACTIVE == state:
            self.buttonCapture.setEnabled(True)
            self.buttonCapture.setText('Capture')

    def setMessageInfo(self,info):
        self.msgInfo.setText(info)

    def setAvailable(self,threads):
        self.sig.emit(threads)

    def toggleThreadDisplay(self,item):
        print(self.listThread.currentRow())
        #if item.isSelected():
        #    print(item.text() + "  is selected")
        #else:
        #    print(item.text() + "  is not selected")
        self.diagramView.showThread(self.listThread.currentRow(),item.isSelected())

    def hideAllMsgNamedAsSelected(self):
        self.diagramView.hideAllMessageSelected()

    def addThreadList(self,threads):

        if not self.groupBoxThreadInfo:
            self.groupBoxThreadInfo = QGroupBox()
            self.threadInfo = QLabel("Thread Info.")
            self.groupBoxThreadInfo.setStyleSheet("QGroupBox {border: 1px solid gray; border-radius: 9px; margin-top: 0.5em} QGroupBox::title {subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px;")

        if not self.threadvbox:
            self.threadvbox = QVBoxLayout()

        if not self.listThread:
            self.listThread = QListWidget()
            
        self.listThread.setFixedWidth(200)
        self.listThread.setSelectionMode(QAbstractItemView.MultiSelection)
        QtCore.QObject.connect(self.listThread, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.toggleThreadDisplay)
        self.threadvbox.addWidget(self.threadInfo)
        self.threadvbox.addWidget(self.listThread)
        self.groupBoxThreadInfo.setLayout(self.threadvbox)
        self.addWidget(self.groupBoxThreadInfo)
        self.groupBoxThreadInfo.setSizePolicy(self.sizePolicy)

        for id in threads:
            item = QListWidgetItem(id)
            self.listThread.addItem(item)

    def connectController(self,controller):
        self.controller = controller
        self.connect(controller,QtCore.SIGNAL('setAvailable()'),self.setAvailable)
       
    def connectDiagramView(self,view):
        self.diagramView = view
 
    def disconnectMsgRcv(self,receiver):
        print("Implement this method !!! disconnectMsgRcv")

    def connectMsgRcv(self,receiver):
        self.msgRcv.append(receiver)

    def notifyHide(self):
        for rcv in self.msgRcv:
            rcv.activateHide(True)

    def showHiddenLifelines(self):
        response, selected_items = HiddenDialog.HiddenDialog.getSelectedItems(self.diagramView.getHiddenLifeLines())
        if response:
            self.diagramView.showLifelines(selected_items)

    def showHiddenMessages(self):
        response, selected_items = HiddenMessageDialog.HiddenMessageDialog.getSelectedItems(self.diagramView.getHiddenMessages(),self.diagramView.getHiddenLifeLines())
        if response:
            if selected_items[3] in self.diagramView.getHiddenLifeLines():
                confirmation = ShowLifeLineDialog.ShowLifeLineDialog.confirmToShowLifeLine(selected_items[3])
                if confirmation:
                    self.diagramView.showLifelines([selected_items[3]])
                    self.diagramView.showMessages(selected_items)
            else:
                self.diagramView.showMessages(selected_items)

    def notifyCapture(self):
        for rcv in self.msgRcv:
            rcv.activateCapture(True)
    
    def moveToPrev(self):
        for rcv in self.msgRcv:
            rcv.moveToPrev()
        
    def moveToNext(self):
        for rcv in self.msgRcv:
            rcv.moveToNext()

    def searchMsg(self):
        str = self.editTextSearch.toPlainText()
        for rcv in self.msgRcv:
            rcv.searchMessage(str)