コード例 #1
0
    def setup_ui(self):
        # Number of Groups
        layout_num_groups = QHBoxLayout()

        rbtn_num_groups = QRadioButton("Number of Groups:")
        rbtn_num_groups.option = 'num_groups'
        rbtn_num_groups.setChecked(True)
        rbtn_num_groups.toggled.connect(self.set_generate_option)

        self.spin_num_groups = QSpinBox()
        self.spin_num_groups.setMinimum(1)
        self.spin_num_groups.setSingleStep(1)

        layout_num_groups.addWidget(rbtn_num_groups)
        layout_num_groups.addWidget(self.spin_num_groups)

        # People per Group
        layout_people_per_group = QHBoxLayout()

        rbtn_num_groups = QRadioButton("People per Group:")
        rbtn_num_groups.option = 'people_per_group'
        rbtn_num_groups.toggled.connect(self.set_generate_option)

        self.spin_people_per_group = QSpinBox()
        self.spin_people_per_group.setMinimum(1)
        self.spin_people_per_group.setSingleStep(1)

        layout_people_per_group.addWidget(rbtn_num_groups)
        layout_people_per_group.addWidget(self.spin_people_per_group)

        # Generate Button
        btn_generate = QPushButton("Generate!")
        btn_generate.setFixedHeight(36)
        btn_generate.clicked.connect(self.generate_groups)

        # Main Layout
        widget = QWidget()
        layout = QVBoxLayout()

        layout.addLayout(layout_num_groups)
        layout.addLayout(layout_people_per_group)
        layout.addWidget(btn_generate)

        widget.setLayout(layout)
        self.setWidget(widget)
コード例 #2
0
    def __init__(self, validation, defaultType, defaultSigmas):
        super().__init__()
        layout = QGridLayout()
        layout.setContentsMargins(5, 4, 0, 0)

        self._typeGroup = QButtonGroup()
        for i, option in enumerate(string.ERROR_TYPE_OPTIONS):
            button = QRadioButton(option)
            button.option = option
            button.setChecked(option == defaultType)
            self._typeGroup.addButton(button, i)
            layout.addWidget(button, 0, i)
        self._typeGroup.buttonReleased.connect(validation)

        self._sigmasGroup = QButtonGroup()
        for i, option in enumerate(string.ERROR_SIGMA_OPTIONS):
            button = QRadioButton(string.get_error_sigmas_str(option))
            button.option = option
            button.setChecked(option == defaultSigmas)
            self._sigmasGroup.addButton(button, i)
            layout.addWidget(button, 1, i)
        self._sigmasGroup.buttonReleased.connect(validation)

        self.setLayout(layout)
コード例 #3
0
    def __init__(self, options, validation, default, rows=None, cols=None):
        super().__init__()

        self.options = options
        self.group = QButtonGroup()
        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        for i, option in enumerate(options):
            button = QRadioButton(option)
            button.option = option
            button.setChecked(option == default)
            self.group.addButton(button, i)
            x, y = self._calculate_coordinates(i, rows, cols)
            layout.addWidget(button, x, y)

        self.group.buttonReleased.connect(validation)

        self.setLayout(layout)