def __init__(self, plotly_args=[], plotly_kwargs={}, parent=None): super(QtPlotlyExporter, self).__init__(parent=parent) self.plotly_args = plotly_args self.plotly_kwargs = plotly_kwargs self.ui = load_ui('exporter.ui', self, directory=os.path.dirname(__file__)) self.button_cancel.clicked.connect(self.reject) self.button_export.clicked.connect(self.accept) # Set up radio button groups self._radio_account = QtWidgets.QButtonGroup() self._radio_account.addButton(self.ui.radio_account_glue) self._radio_account.addButton(self.ui.radio_account_config) self._radio_account.addButton(self.ui.radio_account_manual) self._radio_sharing = QtWidgets.QButtonGroup() self._radio_sharing.addButton(self.ui.radio_sharing_public) self._radio_sharing.addButton(self.ui.radio_sharing_secret) self._radio_sharing.addButton(self.ui.radio_sharing_private) # Find out stored credentials (note that this will create the # credentials file if it doesn't already exist) from plotly import plotly credentials = plotly.get_credentials() config_available = credentials['username'] != "" and credentials[ 'api_key'] != "" if config_available: self.ui.radio_account_config.setChecked(True) label = self.ui.radio_account_config.text() self.ui.radio_account_config.setText( label + " (username: {0})".format(credentials['username'])) else: self.ui.radio_account_glue.setChecked(True) self.ui.radio_account_config.setEnabled(False) self.ui.radio_sharing_secret.setChecked(True) self.ui.text_username.textChanged.connect( nonpartial(self._set_manual_mode)) self.ui.text_api_key.textChanged.connect( nonpartial(self._set_manual_mode)) self.ui.radio_account_glue.toggled.connect( nonpartial(self._set_allowed_sharing_modes)) self.set_status('', color='black') self._set_allowed_sharing_modes()
def __init__(self, parent=None, loaded_dictionary=None, plugin_name=None): super().__init__(parent) # TODO Thinks here what is the best behaviour with buttons in the case of a new fom mode self.setupUi(self) # Communication QButtonGroup self.comm_button_group = QtWidgets.QButtonGroup() # self.comm_button_group.addButton(self.remote_radio_button) # self.comm_button_group.addButton(self.local_radio_button) self.comm_button_group.addButton(self.allinone_radio_button) # Not available buttons self.no_available_button_group = QtWidgets.QButtonGroup() self.no_available_button_group.addButton(self.remote_radio_button) self.no_available_button_group.addButton(self.local_radio_button) self.no_available_button_group.addButton( self.files_exchange_radio_button) self.no_available_button_group.setExclusive(False) # self.test_radio_button.setChecked(True) # Fom QButtonGroup self.fom_button_group = QtWidgets.QButtonGroup() self.fom_button_group.addButton(self.python_class_radio_button) # self.fom_button_group.addButton(self.files_exchange_radio_button) # Create the widget object and set it communication_dictionary, figure_of_merit_dictionary = None, None if loaded_dictionary is not None: communication_dictionary = loaded_dictionary[0] figure_of_merit_dictionary = loaded_dictionary[1] # Comm self.remote_comm_form = RemoteCommForm() self.local_comm_form = LocalCommForm() self.all_in_one_comm_form = AllInOneCommForm( loaded_dictionary=communication_dictionary) # Fom self.python_class_form = PythonClassForm( loaded_dictionary=figure_of_merit_dictionary) self.files_update_form = FilesUpdateForm() # Comm # self.remote_radio_button.pressed.connect(self.set_remote_widget) # self.local_radio_button.pressed.connect(self.set_local_widget) self.allinone_radio_button.pressed.connect(self.set_all_in_one_widget) # Fom self.python_class_radio_button.pressed.connect( self.set_python_class_widget) # self.files_exchange_radio_button.pressed.connect(self.set_files_update_widget) self.no_available_button_group.buttonReleased.connect( self.no_available_button_unchecked) # Initialization self._initialization()
def __init__(self, *args, **kwargs): super(MainWidget, self).__init__(*args, **kwargs) self.collection_tab_btn = QtWidgets.QPushButton('Collection') self.calibration_tab_btn = QtWidgets.QPushButton('Calibration') self.epics_config_btn = QtWidgets.QPushButton('EPICS Config') self._tab_button_group = QtWidgets.QButtonGroup() self._tab_button_group.addButton(self.collection_tab_btn) self._tab_button_group.addButton(self.calibration_tab_btn) self._tab_button_group.addButton(self.epics_config_btn) self._layout = QtWidgets.QVBoxLayout() self._tab_layout = QtWidgets.QHBoxLayout() self._tab_layout.addWidget(self.collection_tab_btn) self._tab_layout.addWidget(self.calibration_tab_btn) self._tab_layout.addWidget(self.epics_config_btn) self.graph_widget = GraphWidget() self.measurement_widget = MeasurementWidget() self.calibration_widget = CalibrationWidget() self._layout.addWidget(self.graph_widget) self._layout.addLayout(self._tab_layout) self._layout.addWidget(self.measurement_widget) self._layout.addWidget(self.calibration_widget) self.setLayout(self._layout) self.set_widget_properties()
def __init__(self, parent): super(PidProperties, self).__init__(parent) self.parent = parent self.module = self.parent.module aws = self.parent.attribute_widgets self.layout = QtWidgets.QHBoxLayout(self) self.v2 = QtWidgets.QVBoxLayout() self.layout.addLayout(self.v2) self.v1 = QtWidgets.QVBoxLayout() self.layout.addLayout(self.v1) self.radio_group = QtWidgets.QButtonGroup() self.manual = QtWidgets.QRadioButton('manual design') self.assisted = QtWidgets.QRadioButton('assisted design') self.radio_group.addButton(self.manual) self.radio_group.addButton(self.assisted) self.assisted.toggled.connect(self.toggle_mode) # only one button of the group must be connected # self.manual.toggled.connect(self.toggle_mode) self.manual_widget = WidgetManual(self) self.v1.addWidget(self.manual) self.v1.addWidget(self.manual_widget) # self.col3.addWidget(aws["tf_filter"]) self.assisted_widget = WidgetAssisted(self) self.v2.insertWidget(0, self.assisted) self.v2.addWidget(self.assisted_widget) self.v2.addStretch(5) self.setTitle("Pid control") for v in (self.v1, self.v2, self.layout): v.setSpacing(0) v.setContentsMargins(5, 1, 0, 0)
def init_modes(self): layout = QtWidgets.QGridLayout() qscale_group_box = QtWidgets.QGroupBox() qscale_group_box.setStyleSheet("QGroupBox{padding-top:5px; margin-top:-18px}") qscale_box_layout = QtWidgets.QHBoxLayout() self.widgets.mode = QtWidgets.QButtonGroup() self.widgets.mode.buttonClicked.connect(self.set_mode) qscale_radio = QtWidgets.QRadioButton("qscale") qscale_radio.setChecked(True) qscale_radio.setFixedWidth(80) self.widgets.mode.addButton(qscale_radio) self.widgets.qscale = QtWidgets.QComboBox() self.widgets.qscale.setFixedWidth(250) self.widgets.qscale.addItems([str(x) for x in range(0, 101, 5)] + ["Custom"]) self.widgets.qscale.setCurrentIndex(15) self.widgets.qscale.currentIndexChanged.connect(lambda: self.mode_update()) self.widgets.custom_qscale = QtWidgets.QLineEdit("75") self.widgets.custom_qscale.setFixedWidth(100) self.widgets.custom_qscale.setDisabled(True) self.widgets.custom_qscale.setValidator(self.only_int) self.widgets.custom_qscale.textChanged.connect(lambda: self.main.build_commands()) qscale_box_layout.addWidget(qscale_radio) qscale_box_layout.addWidget(self.widgets.qscale) qscale_box_layout.addStretch() qscale_box_layout.addWidget(QtWidgets.QLabel("Custom:")) qscale_box_layout.addWidget(self.widgets.custom_qscale) qscale_group_box.setLayout(qscale_box_layout) layout.addWidget(qscale_group_box, 0, 0) return layout
def create_widgets(self): self.configuration_lbl = LabelAlignRight("Configuration:") self.configuration_btns = [] self.configurations_btn_widget = QtWidgets.QWidget() self.configuration_btn_group = QtWidgets.QButtonGroup() self.add_configuration_btn = FlatButton("+") self.remove_configuration_btn = FlatButton("-") self.factor_lbl = LabelAlignRight("Factor: ") self.factor_txt = NumberTextField("1") self.file_lbl = LabelAlignRight("File: ") self.previous_file_btn = FlatButton("<") self.next_file_btn = FlatButton(">") self.file_iterator_pos_lbl = LabelAlignRight(" Pos: ") self.file_iterator_pos_txt = IntegerTextField("1") self.folder_lbl = LabelAlignRight(" Folder:") self.next_folder_btn = FlatButton(">") self.previous_folder_btn = FlatButton("<") self.mec_cb = QtWidgets.QCheckBox("MEC") self.combine_patterns_btn = CheckableFlatButton("Combine Patterns") self.combine_cakes_btn = CheckableFlatButton("Combine Cakes")
def init_modes(self): layout = QtWidgets.QGridLayout() qp_group_box = QtWidgets.QGroupBox() qp_group_box.setStyleSheet("QGroupBox{padding-top:5px; margin-top:-18px}") qp_box_layout = QtWidgets.QHBoxLayout() self.widgets.mode = QtWidgets.QButtonGroup() self.widgets.mode.buttonClicked.connect(self.set_mode) bitrate_group_box = QtWidgets.QGroupBox() bitrate_group_box.setStyleSheet("QGroupBox{padding-top:5px; margin-top:-18px}") bitrate_box_layout = QtWidgets.QHBoxLayout() bitrate_radio = QtWidgets.QRadioButton("Bitrate") bitrate_radio.setFixedWidth(80) self.widgets.mode.addButton(bitrate_radio) self.widgets.bitrate = QtWidgets.QComboBox() self.widgets.bitrate.setFixedWidth(250) self.widgets.bitrate.addItems(recommended_bitrates) self.widgets.bitrate.setCurrentIndex(6) self.widgets.bitrate.currentIndexChanged.connect(lambda: self.mode_update()) self.widgets.custom_bitrate = QtWidgets.QLineEdit("3000") self.widgets.custom_bitrate.setFixedWidth(100) self.widgets.custom_bitrate.setDisabled(True) self.widgets.custom_bitrate.textChanged.connect(lambda: self.main.build_commands()) bitrate_box_layout.addWidget(bitrate_radio) bitrate_box_layout.addWidget(self.widgets.bitrate) bitrate_box_layout.addStretch() bitrate_box_layout.addWidget(QtWidgets.QLabel("Custom:")) bitrate_box_layout.addWidget(self.widgets.custom_bitrate) qp_radio = QtWidgets.QRadioButton("QP") qp_radio.setChecked(True) qp_radio.setFixedWidth(80) self.widgets.mode.addButton(qp_radio) self.widgets.qp = QtWidgets.QComboBox() self.widgets.qp.setFixedWidth(250) self.widgets.qp.addItems(recommended_qp) self.widgets.qp.setCurrentIndex(0) self.widgets.qp.currentIndexChanged.connect(lambda: self.mode_update()) self.widgets.custom_qp = QtWidgets.QLineEdit("30") self.widgets.custom_qp.setFixedWidth(100) self.widgets.custom_qp.setDisabled(True) self.widgets.custom_qp.setValidator(self.only_int) self.widgets.custom_qp.textChanged.connect(lambda: self.main.build_commands()) qp_box_layout.addWidget(qp_radio) qp_box_layout.addWidget(self.widgets.qp) qp_box_layout.addStretch() qp_box_layout.addWidget(QtWidgets.QLabel("Custom:")) qp_box_layout.addWidget(self.widgets.custom_qp) bitrate_group_box.setLayout(bitrate_box_layout) qp_group_box.setLayout(qp_box_layout) bitrate_group_box.setLayout(bitrate_box_layout) qp_group_box.setLayout(qp_box_layout) layout.addWidget(qp_group_box, 0, 0) layout.addWidget(bitrate_group_box, 1, 0) return layout
def __init__(self, parent=None, switch_states=('Off', 'On')): assert len(switch_states ) >= 2, 'switch_states must be tuple of at least 2 strings' assert all(isinstance(s, str) and s for s in switch_states), \ 'switch state must be non-empty str' super().__init__(parent=parent) layout = QtWidgets.QHBoxLayout() layout.setAlignment(QtCore.Qt.AlignCenter) layout.setContentsMargins(2, 2, 2, 2) self.setLayout(layout) self.switch_states = tuple(switch_states) self._state_colors = (None, None) self.radio_buttons = { state: QtWidgets.QRadioButton() for state in switch_states } self._labels = { state: QtWidgets.QLabel(state) for state in switch_states } button_group = QtWidgets.QButtonGroup(self) for ii, (state, button) in enumerate(self.radio_buttons.items()): button.setLayoutDirection(QtCore.Qt.RightToLeft) button_group.addButton(button, ii) label = self._labels[state] label.setTextFormat(QtCore.Qt.RichText) label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) layout.addWidget(button) layout.addWidget(label) layout.addStretch() button_group.buttonToggled.connect(self.__button_toggled_cb)
def __init__(self, layer_artist): super(VolumeLayerStyleWidget, self).__init__() self.ui = load_ui('layer_style_widget.ui', self, directory=os.path.dirname(__file__)) self.state = layer_artist.state if self.state.subset_mode == 'outline': self.ui.radio_subset_outline.setChecked(True) else: self.ui.radio_subset_data.setChecked(True) self.layer_artist = layer_artist self.layer = layer_artist.layer # autoconnect needs to come after setting up the component IDs connect_kwargs = {'value_alpha': dict(value_range=(0., 1.))} self._connections = autoconnect_callbacks_to_qt(self.state, self.ui, connect_kwargs) # Set up radio buttons for subset mode selection if this is a subset if isinstance(self.layer, Subset): self._radio_size = QtWidgets.QButtonGroup() self._radio_size.addButton(self.ui.radio_subset_outline) self._radio_size.addButton(self.ui.radio_subset_data) self.ui.radio_subset_outline.toggled.connect(self._update_subset_mode) self.ui.radio_subset_data.toggled.connect(self._update_subset_mode) self.ui.valuetext_vmin.hide() self.ui.valuetext_vmax.hide() self.ui.label_limits.hide() else: self.ui.radio_subset_outline.hide() self.ui.radio_subset_data.hide() self.ui.label_subset_mode.hide()
def __init__(self, *args, **kwargs): super(ModeSwitchWidget, self).__init__(*args, **kwargs) self._main_layout = QtWidgets.QVBoxLayout() self._grid_layout = QtWidgets.QGridLayout() self.caption = QtWidgets.QLabel('Normal/Pulsed Modes') self._main_layout.addWidget(self.caption) self._main_layout.addLayout(self._grid_layout) self.ds_laser_lbl = QtWidgets.QLabel('DS Laser Mode:') self.ds_laser_normal_btn = QtWidgets.QPushButton('Normal') self.ds_laser_pulsed_btn = QtWidgets.QPushButton('Pulsed') self.ds_laser_btn_group = QtWidgets.QButtonGroup() self.ds_laser_btn_group.addButton(self.ds_laser_pulsed_btn) self.ds_laser_btn_group.addButton(self.ds_laser_normal_btn) self.us_laser_lbl = QtWidgets.QLabel('DS Laser Mode:') self.us_laser_normal_btn = QtWidgets.QPushButton('Normal') self.us_laser_pulsed_btn = QtWidgets.QPushButton('Pulsed') self.us_laser_btn_group = QtWidgets.QButtonGroup() self.us_laser_btn_group.addButton(self.us_laser_pulsed_btn) self.us_laser_btn_group.addButton(self.us_laser_normal_btn) self.pimax_lbl = QtWidgets.QLabel('PIMAX Mode:') self.pimax_to_normal_btn = QtWidgets.QPushButton('Normal') self.pimax_to_pulsed_btn = QtWidgets.QPushButton('Pulsed') self.pimax_btn_group = QtWidgets.QButtonGroup() self.pimax_btn_group.addButton(self.pimax_to_normal_btn) self.pimax_btn_group.addButton(self.pimax_to_pulsed_btn) self._grid_layout.addWidget(self.ds_laser_lbl, 0, 0) self._grid_layout.addWidget(self.ds_laser_normal_btn, 0, 1) self._grid_layout.addWidget(self.ds_laser_pulsed_btn, 0, 2) self._grid_layout.addWidget(self.us_laser_lbl, 1, 0) self._grid_layout.addWidget(self.us_laser_normal_btn, 1, 1) self._grid_layout.addWidget(self.us_laser_pulsed_btn, 1, 2) self._grid_layout.addWidget(self.pimax_lbl, 2, 0) self._grid_layout.addWidget(self.pimax_to_normal_btn, 2, 1) self._grid_layout.addWidget(self.pimax_to_pulsed_btn, 2, 2) self.setLayout(self._main_layout) self.style_widgets()
def __init__(self, display, splitter): QtWidgets.QWidget.__init__(self) self.display = display display.sigLayerChanged.connect(self.toggleDataChanged) display.sigNewLayer.connect(self.toggleNewData) self.setMinimumHeight(30) self.splitter = splitter self._collect = False self._activeWidgets = [] # LAYOUT layout = QtWidgets.QVBoxLayout() layout.setAlignment(QtCore.Qt.AlignTop) # setMargin removed. obsolete, doesn't do anything, not even in PyQt4 self.setLayout(layout) self._hl = QtWidgets.QHBoxLayout() layout.addLayout(self._hl) # BUTTON: show/hide 'Scripts' self.btn_scripts = QtWidgets.QRadioButton('Scripts') f = self.btn_scripts.font() f.setBold(True) self.btn_scripts.setFont(f) self.btn_scripts.clicked.connect(self._uncheckConsole) self.btn_scripts.clicked.connect(self._toggleScriptsFirstTime) self.btn_scripts.clicked.connect(self.updateSize) self._hl.addWidget(self.btn_scripts) # BUTTON: show/hide 'Console' self.btn_console = QtWidgets.QRadioButton('Console') f = self.btn_console.font() f.setBold(True) self.btn_console.setFont(f) self.btn_console.clicked.connect(self._uncheckScripts) self.btn_console.clicked.connect(self._toggleConsoleFirstTime) self.btn_console.clicked.connect(self.updateSize) self._hl.addWidget(self.btn_console) g = QtWidgets.QButtonGroup(self) g.setExclusive(False) g.addButton(self.btn_scripts) g.addButton(self.btn_console) self.splitter.setStretchFactor(0, 0) self.cb_run_on = QtWidgets.QComboBox() self.cb_run_on.addItems(['-', 'New Data', 'Data Changed']) self.tabs = FwTabWidget() self.tabs.hide() self.tabs.setTabsAddable(True) self.tabs.setTabsClosable(True) self.tabs.setTabsRenamable(True)
def create_widgets(self): self.project_browser_label = QtWidgets.QLabel('Project Browser') self.assets_button = QtWidgets.QPushButton() self.production_button = QtWidgets.QPushButton() self.search_bar = ui_search_bar.UiSearchBar(height=30) self.stem_type_button_grp = QtWidgets.QButtonGroup() self.stem_tree = StemTree() self.reload_button = reload_button.ReloadButton() self.filter_button = filter_button.FilterButton()
def __init__(self, title='Detectors', *, detectors, **kwargs): super().__init__(title, **kwargs) self.button_group = QtWidgets.QButtonGroup() self.button_group.setExclusive(False) vlayout = QtWidgets.QVBoxLayout() self.setLayout(vlayout) for d in detectors: button = DetectorCheck(d) self.button_group.addButton(button) vlayout.addWidget(button)
def __init__(self, parent=None, artist=None): super(RGBEdit, self).__init__(parent) self._artist = artist l = QtWidgets.QGridLayout() current = QtWidgets.QLabel("Contrast") visible = QtWidgets.QLabel("Visible") l.addWidget(current, 0, 2, 1, 1) l.addWidget(visible, 0, 3, 1, 1) l.setColumnStretch(0, 0) l.setColumnStretch(1, 10) l.setColumnStretch(2, 0) l.setColumnStretch(3, 0) l.setRowStretch(0, 0) l.setRowStretch(1, 0) l.setRowStretch(2, 0) l.setRowStretch(3, 0) l.setRowStretch(4, 10) curr_grp = QtWidgets.QButtonGroup() self.current = {} self.vis = {} self.cid = {} for row, color in enumerate(['red', 'green', 'blue'], 1): lbl = QtWidgets.QLabel(color.title()) cid = ComponentIDCombo() curr = QtWidgets.QRadioButton() curr_grp.addButton(curr) vis = QtWidgets.QCheckBox() vis.setChecked(True) l.addWidget(lbl, row, 0, 1, 1) l.addWidget(cid, row, 1, 1, 1) l.addWidget(curr, row, 2, 1, 1) l.addWidget(vis, row, 3, 1, 1) curr.clicked.connect(self.update_current) vis.toggled.connect(self.update_visible) cid.currentIndexChanged.connect(self.update_layers) self.cid[color] = cid self.vis[color] = vis self.current[color] = curr self.setLayout(l) self.current['red'].click()
def __init__(self, parent): super(AnalogTfDialog, self).__init__(parent) self.parent = parent self.module = self.parent.module self.setWindowTitle("Analog transfer function for output %s" % self.module.name) self.lay_v = QtWidgets.QVBoxLayout(self) self.lay_h = QtWidgets.QHBoxLayout() self.ok = QtWidgets.QPushButton('Ok') self.lay_h.addWidget(self.ok) self.ok.clicked.connect(self.validate) self.cancel = QtWidgets.QPushButton('Cancel') self.lay_h.addWidget(self.cancel) self.group = QtWidgets.QButtonGroup() self.flat = QtWidgets.QRadioButton("Flat response") self.filter = QtWidgets.QRadioButton( 'Analog low-pass filter (as in "Pid control/assisted design/actuator cut-off")' ) self.curve = QtWidgets.QRadioButton("User-defined curve") self.group.addButton(self.flat) self.group.addButton(self.filter) self.group.addButton(self.curve) self.lay_v.addWidget(self.flat) self.lay_v.addWidget(self.filter) self.lay_v.addWidget(self.curve) self.label = QtWidgets.QLabel("Curve #") self.line = QtWidgets.QLineEdit("coucou") self.lay_line = QtWidgets.QHBoxLayout() self.lay_v.addLayout(self.lay_line) self.lay_v.addWidget(self.line) self.lay_line.addStretch(1) self.lay_line.addWidget(self.label) self.lay_line.addWidget(self.line, stretch=10) self.lay_v.addSpacing(20) self.lay_v.addLayout(self.lay_h) self.curve.toggled.connect(self.change_visibility) { 'flat': self.flat, 'filter': self.filter, 'curve': self.curve }[self.module.tf_type].setChecked(True) self.line.setText(str(self.module.tf_curve)) self.line.textEdited.connect(lambda: self.line.setStyleSheet("")) self.cancel.clicked.connect(self.reject) self.curve_id = None self.res = None
def __init__(self, title, keys, parent=None): super(Radiodemo, self).__init__(parent) hbl = QtWidgets.QHBoxLayout(self) hbl.setSpacing(0) hbl.setContentsMargins(0, 0, 0, 0) label = QtWidgets.QLabel(title) hbl.addWidget(label) self.cs_group = QtWidgets.QButtonGroup() for i, k in enumerate(keys): btn = QtWidgets.QRadioButton(k) if i == 0: btn.setChecked(True) hbl.addWidget(btn) self.cs_group.addButton(btn) self.cs_group.buttonClicked.connect(self.btnstate)
def _add_unet_2d_prediction_params(self): self.model_file_line_edit = LineEdit(default="Filepath", parse=str) model_input_btn = PushButton("Select Model", accent=True) model_input_btn.clicked.connect(self.get_model_path) self.radio_group = QtWidgets.QButtonGroup() self.radio_group.setExclusive(True) single_pp_rb = QRadioButton("Single plane") single_pp_rb.setChecked(True) self.radio_group.addButton(single_pp_rb, 1) triple_pp_rb = QRadioButton("Three plane") self.radio_group.addButton(triple_pp_rb, 3) self.add_row( HWidgets(self.model_file_line_edit, model_input_btn, Spacing(35))) self.add_row(HWidgets("Prediction Parameters:", Spacing(35), stretch=1)) self.add_row(HWidgets(single_pp_rb, triple_pp_rb, stretch=1))
def _confirm_add_team(self): self.progress.quit() self.progess = None self.repos = matching_repositories(self.repos, self.pattern) print(self.repos.columns) self.repos = self.repos.loc[~self.repos.id.isin(self.team_repos.id)] self.repos = self.repos.sort_values('name') N = len(self.repos.index) label = QtWidgets.QLabel() label.setText((f"Add team {self.team} to {N} repositories?\n" + "Double click repository to view on GitHub.")) model = PandasModel(self.repos[['name']]) table = QtWidgets.QListView() table.setModel(model) table.doubleClicked.connect(self._open_repo) groupbox = QtWidgets.QGroupBox("Permission:") self.team_permission = QtWidgets.QButtonGroup() radios = [ QtWidgets.QRadioButton("Pull"), QtWidgets.QRadioButton("Push"), QtWidgets.QRadioButton("Admin") ] radios[0].setChecked(1) hbox = QtWidgets.QHBoxLayout() for key, radio in enumerate(radios): self.team_permission.addButton(radio) self.team_permission.setId(radio, key) hbox.addWidget(radio) groupbox.setLayout(hbox) buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.search_popup = Popup(label, table, groupbox, title="Add Team", bbox=buttons) buttons.accepted.connect(self._do_add_team) self.search_popup.show()
def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle("My calculator") widget = QtWidgets.QWidget() self.setCentralWidget(widget) self.layout = QtWidgets.QVBoxLayout() widget.setLayout(self.layout) self.canvas = FigureCanvas(Figure(figsize=(5, 3))) # self.addToolBar(NavigationToolbar(self.canvas, self)) self.layout.addWidget(self.canvas) self.ax = self.canvas.figure.subplots() self.lines = [] hlayout = QtWidgets.QHBoxLayout() button = QtWidgets.QPushButton("redraw") button.clicked.connect(self.redraw) self.layout.addWidget(button) self.grid = None self.text = QtWidgets.QLineEdit() self.text.setText("x") self.grid = QtWidgets.QGridLayout() self.grid.setColumnStretch(1, 1) self.grid.setColumnStretch(1, 20) self.grid.setColumnStretch(2, 1) btc = QtWidgets.QToolButton() self.color = "blue" btc.setStyleSheet(f"background: {self.color};") btc.update() self.grid.addWidget(btc, 0, 0) self.grid.addWidget(self.text, 0, 1) self.bgc = QtWidgets.QButtonGroup() self.bgc.addButton(btc) self.bgc.buttonClicked.connect(self.set_color) self.layout.addLayout(self.grid) self.redraw()
def select_joystick(self): """Select a gamepad if there is no joystick selected.""" try: self._dialog.close() except AttributeError: pass self._dialog = QtWidgets.QDialog() layout = QtWidgets.QVBoxLayout() self._dialog.setLayout(layout) # Joysticks btngroup = QtWidgets.QButtonGroup() btngroup.setExclusive(True) for item in self.get_joysticks(): btn = QtWidgets.QRadioButton(item.get_name()) layout.addWidget(btn) btngroup.addButton(btn) # Accept method def select(): btn = btngroup.checkedButton() joystick = None if btn is not None: name = btn.text() for joy in self.get_joysticks(): if joy.get_name() == name: joystick = joy break self.set_joystick(joystick) self._dialog.close() # Buttons accept = QtWidgets.QPushButton("Select") accept.clicked.connect(select) cancel = QtWidgets.QPushButton("Cancel") cancel.clicked.connect(self._dialog.close) # Button layout hlay = QtWidgets.QHBoxLayout() hlay.addWidget(accept, alignment=QtCore.Qt.AlignRight) hlay.addWidget(cancel, alignment=QtCore.Qt.AlignRight) layout.addLayout(hlay) self._dialog.show()
def __init__(self, name, option_list, vertical=True, **kwargs): self._name = name super().__init__(title='', **kwargs) self.button_group = QtWidgets.QButtonGroup() self.button_group.setExclusive(False) if vertical: MainLayout = QtWidgets.QVBoxLayout() else: MainLayout = QtWidgets.QHBoxLayout() self.setLayout(MainLayout) for item in option_list: item_name = getattr(item, 'name', str(item)) button = QtWidgets.QCheckBox(item_name, **kwargs) setattr(button, 'item', item) self.button_group.addButton(button) MainLayout.addWidget(button) # sets the layout width and height to fit inclosed widgets self.layout().setSizeConstraint(QtWidgets.QLayout.SetFixedSize) # ensure that the background is auto-filled self.setAutoFillBackground(True)
def __init__(self, parent=None): super().__init__(parent) # Widgets, layouts and signals self._group = QtWidgets.QButtonGroup() layout = QtWidgets.QGridLayout() layout.setSpacing(0) for i in range(18): layout.setColumnMinimumWidth(i, 40) layout.setColumnStretch(i, 0) for i in list(range(7)) + [8, 9]: layout.setRowMinimumHeight(i, 40) layout.setRowStretch(i, 0) ## Element for z, position in _ELEMENT_POSITIONS.items(): widget = ElementPushButton(z) widget.setCheckable(True) layout.addWidget(widget, *position) self._group.addButton(widget, z) ## Labels layout.addWidget(QtWidgets.QLabel(""), 7, 0) # Dummy layout.addWidget(QtWidgets.QLabel("*"), 5, 2, QtCore.Qt.AlignCenter) layout.addWidget(QtWidgets.QLabel("*"), 8, 2, QtCore.Qt.AlignCenter) layout.addWidget(QtWidgets.QLabel("**"), 6, 2, QtCore.Qt.AlignCenter) layout.addWidget(QtWidgets.QLabel("**"), 9, 2, QtCore.Qt.AlignCenter) for row in [0, 1, 2, 3, 4, 5, 6, 8, 9]: layout.setRowStretch(row, 1) self.setLayout(layout) # Signals self._group.buttonClicked.connect(self._on_button_clicked) # Default self.setColorFunction(_category_color_function)
def __init__(self, device: microscope.abc.FilterWheel, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self._device = device self._button_grp = QtWidgets.QButtonGroup(self) for i in range(self._device.n_positions): button = QtWidgets.QPushButton(str(i + 1), parent=self) button.setCheckable(True) self._button_grp.addButton(button, i) self._button_grp.button(self._device.position).setChecked(True) # We use buttonClicked instead of idClicked because that # requires Qt 5.15 which is too recent. Once we can use # idClicked, then the slot will automatically get the wanted # position. self._button_grp.buttonClicked.connect(self.setFilterWheelPosition) layout = QtWidgets.QVBoxLayout() for button in self._button_grp.buttons(): layout.addWidget(button) self.setLayout(layout)
def __init__(self, parent=None): super(bPlotToolBar, self).__init__(parent) # # radio buttons to select (Nodes, Edges, Annotations) typeButtonGroup = QtWidgets.QButtonGroup(self) typeList = ['Nodes', 'Edges'] #, 'Annotations'] for typeStr in typeList: oneRadioButton = QtWidgets.QRadioButton(typeStr) if typeStr == 'Nodes': oneRadioButton.setChecked(True) oneRadioButton.toggled.connect(self.myRadioCallback) # add to group typeButtonGroup.addButton(oneRadioButton) # add to self self.addWidget(oneRadioButton) # # checkbox to toggle (scatter, histogram) aCheckbox = QtWidgets.QCheckBox('Histogram') aCheckbox.setChecked(False) aCheckbox.stateChanged.connect(self.histogramCallback) self.addWidget(aCheckbox) ''' # show selected point self.pointLabel = QtWidgets.QLabel('Selection:None') self.addWidget(self.pointLabel) ''' #aPushButton = QtWidgets.QPushButton('Selection Square') #self.addWidget(aPushButton) self.button_action = QtWidgets.QAction('Selection []', self) self.button_action.setToolTip("Toggle selection square") self.button_action.setShortcut('r') # or 'Ctrl+r' or '&r' for alt+r self.button_action.setCheckable(True) self.button_action.triggered.connect(self.onMyToolBarButtonClick) self.addAction(self.button_action)
def _createWidget(self): widgetlst = [] w = QtWidgets.QWidget() self._group = QtWidgets.QButtonGroup(w) for i, option in enumerate(self._options): btn = QtWidgets.QRadioButton(option) btn.clicked.connect(lambda: self.changed.emit(self.getValue())) self._group.addButton(btn, i) widgetlst.append(btn) if (self._sub_parameters is not None and self._sub_parameters[i]): subwid = QtWidgets.QWidget() subpars = [par.getWidget() for par in self._sub_parameters[i]] layout = ArrangeV(*subpars) # set top,right,left to 0, right to 11 (should be default on most platforms) layout.setContentsMargins(11, 0, 0, 0) subwid.setLayout(layout) btn.toggled.connect(subwid.setVisible) widgetlst.append(subwid) if (option == self._default_value): btn.setChecked(True) else: btn.toggled.emit(False) w.setLayout(ArrangeV(*widgetlst)) return w
def __init__(self, device: microscope.abc.Controller, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self._device = device self._button2window: typing.Dict[ QtWidgets.QPushButton, typing.Optional[QtWidgets.QMainWindow]] = {} self._button2name: typing.Dict[QtWidgets.QPushButton, str] = {} self._button_grp = QtWidgets.QButtonGroup(self) self._button_grp.setExclusive(False) for name in self._device.devices.keys(): button = QtWidgets.QPushButton(name, parent=self) button.setCheckable(True) self._button_grp.addButton(button) self._button2name[button] = name self._button2window[button] = None self._button_grp.buttonToggled.connect(self.toggleDeviceWidget) layout = QtWidgets.QVBoxLayout() for button in self._button_grp.buttons(): layout.addWidget(button) self.setLayout(layout)
def createToolbars(self) -> None: self.createViewToolbar() self.bg = QtWidgets.QButtonGroup() self.bg.setExclusive(True) self.bg.buttonClicked.connect(self.toolBarChanged) toolbar = self.addToolBar("Tool Selection") self.tool_map: Dict[int, BaseTool] = {} self.current_tool = None for n, tt in enumerate(TOOLS): tool = tt(self.project) toolbutton = tool.getToolButton() self.tool_map[toolbutton] = tool self.bg.addButton(toolbutton) toolbar.addWidget(toolbutton) toolbutton.setCheckable(True) if n == 0: toolbutton.setChecked(True) self.toolBarChanged(toolbutton)
def __init__(self, *args, **kwargs): super(MainWidget, self).__init__(*args, **kwargs) self._outer_layout = QtWidgets.QHBoxLayout() self._outer_layout.setContentsMargins(0, 7, 7, 7) self._outer_layout.setSpacing(0) self._left_layout = QtWidgets.QVBoxLayout() self._left_layout.setContentsMargins(0, 0, 0, 0) self._left_layout.setSpacing(7) self._menu_layout = QtWidgets.QVBoxLayout() self._menu_layout.setContentsMargins(5, 0, 3, 0) self._menu_layout.setSpacing(5) self._mode_layout = QtWidgets.QVBoxLayout() self._mode_layout.setContentsMargins(10, 0, 0, 0) self._mode_layout.setSpacing(0) self.show_configuration_menu_btn = CheckableFlatButton('C') self.save_btn = FlatButton() self.load_btn = FlatButton() self.reset_btn = FlatButton() self.mode_btn_group = QtWidgets.QButtonGroup() self.calibration_mode_btn = RotatedCheckableFlatButton( 'Calibration', self) self.calibration_mode_btn.setObjectName('calibration_mode_btn') self.calibration_mode_btn.setChecked(True) self.mask_mode_btn = RotatedCheckableFlatButton('Mask', self) self.mask_mode_btn.setObjectName('mask_mode_btn') self.integration_mode_btn = RotatedCheckableFlatButton( 'Integration', self) self.integration_mode_btn.setObjectName('integration_mode_btn') self.mode_btn_group.addButton(self.calibration_mode_btn) self.mode_btn_group.addButton(self.mask_mode_btn) self.mode_btn_group.addButton(self.integration_mode_btn) self._menu_layout.addWidget(self.show_configuration_menu_btn) self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(15, 15, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.load_btn) self._menu_layout.addWidget(self.save_btn) self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.reset_btn) self._mode_layout.addWidget(self.calibration_mode_btn) self._mode_layout.addWidget(self.mask_mode_btn) self._mode_layout.addWidget(self.integration_mode_btn) self._left_layout.addLayout(self._menu_layout) self._left_layout.addSpacerItem(VerticalSpacerItem()) self._left_layout.addLayout(self._mode_layout) self._left_layout.addSpacerItem(VerticalSpacerItem()) self._left_layout.setStretch(1, 9) self._left_layout.setStretch(3, 18) self._outer_layout.addLayout(self._left_layout) self._inner_layout = QtWidgets.QVBoxLayout() self._inner_layout.setContentsMargins(0, 0, 0, 0) self._inner_layout.setSpacing(0) self.configuration_widget = ConfigurationWidget(self) self.configuration_widget.setVisible(False) self._inner_layout.addWidget(self.configuration_widget) self.tabWidget = QtWidgets.QTabWidget() self.tabWidget.setTabPosition(QtWidgets.QTabWidget.West) self.tabWidget.setCurrentIndex(0) self.main_frame = QtWidgets.QFrame(self) self.main_frame.setObjectName("main_frame") self._layout_main_frame = QtWidgets.QVBoxLayout() self._layout_main_frame.setContentsMargins(6, 10, 6, 6) self._layout_main_frame.setSpacing(0) self.main_frame.setLayout(self._layout_main_frame) self.calibration_widget = CalibrationWidget(self) self.mask_widget = MaskWidget(self) self.integration_widget = IntegrationWidget(self) self._layout_main_frame.addWidget(self.calibration_widget) self._layout_main_frame.addWidget(self.mask_widget) self._layout_main_frame.addWidget(self.integration_widget) self.mask_widget.setVisible(False) self.integration_widget.setVisible(False) self._inner_layout.addWidget(self.main_frame) self._outer_layout.addLayout(self._inner_layout) self.setLayout(self._outer_layout) self.set_system_dependent_stylesheet() self.set_stylesheet() self.style_widgets() self.add_tooltips() self.setWindowIcon(QtGui.QIcon(os.path.join(icons_path, 'icon.svg')))
def __init__(self, package='', **kwargs): super(UnpackTab, self).__init__(**kwargs) layout = QtWidgets.QGridLayout() layout.addWidget(QtWidgets.QLabel("RPZ package:"), 0, 0) self.package_widget = QtWidgets.QLineEdit(package, enabled=False) layout.addWidget(self.package_widget, 0, 1) browse_pkg = QtWidgets.QPushButton("Browse") browse_pkg.clicked.connect(self._browse_pkg) layout.addWidget(browse_pkg, 0, 2) layout.addWidget(QtWidgets.QLabel("Unpacker:"), 1, 0, QtCore.Qt.AlignTop) ulayout = QtWidgets.QVBoxLayout() self.unpackers = QtWidgets.QButtonGroup() for i, name in enumerate(n for n, c in self.UNPACKERS): radio = QtWidgets.QRadioButton(name) radio.unpacker = name self.unpackers.addButton(radio, i) ulayout.addWidget(radio) layout.addLayout(ulayout, 1, 1, 1, 2) group = QtWidgets.QGroupBox(title="Unpacker options") group_layout = QtWidgets.QVBoxLayout() self.unpacker_options = ResizableStack() self.unpackers.buttonClicked[int].connect( self.unpacker_options.setCurrentIndex) scroll = QtWidgets.QScrollArea(widgetResizable=True) scroll.setWidget(self.unpacker_options) group_layout.addWidget(scroll) group.setLayout(group_layout) layout.addWidget(group, 2, 0, 1, 3) layout.setRowStretch(2, 1) for i, (name, WidgetClass) in enumerate(self.UNPACKERS): widget = WidgetClass() self.unpacker_options.addWidget(widget) self.unpacker_options.addWidget( QtWidgets.QLabel("Select an unpacker to display options...")) self.unpacker_options.setCurrentIndex(len(self.UNPACKERS)) layout.addWidget(QtWidgets.QLabel("Destination directory:"), 3, 0) self.directory_widget = QtWidgets.QLineEdit() self.directory_widget.editingFinished.connect(self._directory_changed) layout.addWidget(self.directory_widget, 3, 1) browse_dir = QtWidgets.QPushButton("Browse") browse_dir.clicked.connect(self._browse_dir) layout.addWidget(browse_dir, 3, 2) buttons = QtWidgets.QHBoxLayout() buttons.addStretch(1) self.unpack_widget = QtWidgets.QPushButton("Unpack experiment", enabled=False) self.unpack_widget.clicked.connect(self._unpack) buttons.addWidget(self.unpack_widget) layout.addLayout(buttons, 4, 0, 1, 3) self.setLayout(layout) self._package_changed()
def __init__(self): super().__init__(QtW.QGroupBox, "", "", "") self._btn_group = QtW.QButtonGroup(self._qwidget) self._mgui_set_orientation("vertical") self._btn_group.buttonToggled.connect(self._emit_data)