def setup_page(self): lblMethod = QLabel(_("Method")) self.rbAuto = QRadioButton(_("Auto")) self.rbEqual = QRadioButton(_("Equal")) self.rbFixed = QRadioButton(_("Fixed")) bgSystem = QButtonGroup() bgSystem.addButton(self.rbAuto) bgSystem.addButton(self.rbEqual) bgSystem.addButton(self.rbFixed) hbox = QHBoxLayout() hbox.addWidget(lblMethod) hbox.addWidget(self.rbAuto) hbox.addWidget(self.rbEqual) hbox.addWidget(self.rbFixed) self.layout.addLayout(hbox) text = _("Fixed ratio Y/X") self.ratio = self.create_lineedit(text, default='1.0') self.layout.addWidget(self.ratio) action = self.create_action() self.layout.addWidget(action) self.rbAuto.toggled.connect(lambda: self.set_method(self.rbAuto)) self.rbEqual.toggled.connect(lambda: self.set_method(self.rbEqual)) self.rbFixed.toggled.connect(lambda: self.set_method(self.rbFixed)) self.rbEqual.setChecked(True) self.ratio.setEnabled(False)
def createLayout(self): hbox = QHBoxLayout() self.radio_clockwise = QRadioButton(self.tr("clockwise"), self) self.radio_clockwise.clockwise = True self.radio_clockwise.setChecked(self.clockwise) self.radio_clockwise.toggled.connect(self.rotationDirectionChanged) self.radio_anticlockwise = QRadioButton(self.tr("anticlockwise"), self) self.radio_anticlockwise.clockwise = False self.radio_anticlockwise.setChecked(not self.clockwise) self.radio_anticlockwise.toggled.connect(self.rotationDirectionChanged) self.angle_editor = QSpinBox(self) self.angle_editor.setButtonSymbols( QtWidgets.QAbstractSpinBox.NoButtons) self.angle_editor.setRange(0, 360) self.angle_editor.setSuffix(" °") self.angle_editor.setValue(self.angle) self.angle_editor.setToolTip("rotation angle") self.angle_editor.setStatusTip(self.toolTip()) self.angle_editor.setAlignment(QtCore.Qt.AlignCenter) self.angle_editor.valueChanged.connect(self.rotationAngleChanged) hbox.addWidget(self.radio_anticlockwise) hbox.addWidget(self.radio_clockwise) hbox.addWidget(self.angle_editor) self.rotate_bar = AngleBar(self, self.clockwise, self.angle, self.angleBarChanged) vbox = QVBoxLayout() vbox.addLayout(hbox) vbox.addWidget(self.rotate_bar) return vbox
def __init__(self, parent): QWidget.__init__(self, parent) vert_layout = QVBoxLayout() # Type frame type_layout = QHBoxLayout() type_label = QLabel(_("Import as")) type_layout.addWidget(type_label) self.array_btn = array_btn = QRadioButton(_("array")) array_btn.setEnabled(ndarray is not FakeObject) array_btn.setChecked(ndarray is not FakeObject) type_layout.addWidget(array_btn) list_btn = QRadioButton(_("list")) list_btn.setChecked(not array_btn.isChecked()) type_layout.addWidget(list_btn) if pd: self.df_btn = df_btn = QRadioButton(_("DataFrame")) df_btn.setChecked(False) type_layout.addWidget(df_btn) h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) type_layout.addItem(h_spacer) type_frame = QFrame() type_frame.setLayout(type_layout) self._table_view = PreviewTable(self) vert_layout.addWidget(type_frame) vert_layout.addWidget(self._table_view) self.setLayout(vert_layout)
def __init__(self, parent=None, emphasized=False): super().__init__(parent) self.setProperty('emphasized', emphasized) self.tab1 = QWidget() self.tab1.setProperty('emphasized', emphasized) self.tab2 = QWidget() self.tab2.setProperty('emphasized', emphasized) self.addTab(self.tab1, "Tab 1") self.addTab(self.tab2, "Tab 2") layout = QFormLayout() layout.addRow("Height", QSpinBox()) layout.addRow("Weight", QDoubleSpinBox()) self.setTabText(0, "Tab 1") self.tab1.setLayout(layout) layout2 = QFormLayout() sex = QHBoxLayout() sex.addWidget(QRadioButton("Male")) sex.addWidget(QRadioButton("Female")) layout2.addRow(QLabel("Sex"), sex) layout2.addRow("Date of Birth", QLineEdit()) self.setTabText(1, "Tab 2") self.tab2.setLayout(layout2) self.setWindowTitle("tab demo")
def create_controls(self): """ Create UI controls. """ vbox = QVBoxLayout() form = QFormLayout() self.num_angle = QDoubleSpinBox() self.num_angle.setValue(0.0) self.num_angle.setMinimum(-360) self.num_angle.setMaximum(360) form.addRow(tr("Angle:"), self.num_angle) vbox.addLayout(form) self.gbo_preview = QGroupBox(tr("Preview")) self.gbo_preview.setCheckable(True) self.gbo_preview.setChecked(False) gbo_vbox = QVBoxLayout() self.chk_grid = QCheckBox(tr("Grid")) self.chk_grid.setChecked(False) self.num_grid = QSpinBox() self.num_grid.setValue(4) self.num_grid.setMinimum(1) self.num_grid.setEnabled(False) self.chk_grid.toggled[bool].connect(self.num_grid.setEnabled) gbo_vbox.addWidget(self.chk_grid) gbo_vbox.addWidget(self.num_grid) self.gbo_preview.setLayout(gbo_vbox) vbox.addWidget(self.gbo_preview) self.gbo_preview.toggled[bool].connect(self.set_preview) self.gbo_output = QGroupBox(tr("Output")) self.opt_new = QRadioButton(tr("New signal")) self.opt_replace = QRadioButton(tr("In place")) self.opt_new.setChecked(True) gbo_vbox2 = QVBoxLayout() gbo_vbox2.addWidget(self.opt_new) gbo_vbox2.addWidget(self.opt_replace) self.gbo_output.setLayout(gbo_vbox2) vbox.addWidget(self.gbo_output) self.chk_reshape = QCheckBox(tr("Resize to fit")) self.chk_reshape.setChecked(False) vbox.addWidget(self.chk_reshape) self.btn_ok = QPushButton(tr("&OK")) self.btn_ok.setDefault(True) self.btn_ok.clicked.connect(self.accept) self.btn_cancel = QPushButton(tr("&Cancel")) self.btn_cancel.clicked.connect(self.reject) hbox = QHBoxLayout() hbox.addWidget(self.btn_ok) hbox.addWidget(self.btn_cancel) vbox.addLayout(hbox) vbox.addStretch(1) self.setLayout(vbox)
def __init__(self, theme='dark', emphasized=False): super().__init__(None) self.setProperty('emphasized', emphasized) self.setStyleSheet(template(raw_stylesheet, **palettes[theme])) lay = QVBoxLayout() self.setLayout(lay) lay.addWidget(QPushButton('push button')) box = QComboBox() box.addItems(['a', 'b', 'c', 'cd']) lay.addWidget(box) lay.addWidget(QFontComboBox()) hbox = QHBoxLayout() chk = QCheckBox('tristate') chk.setToolTip('I am a tooltip') chk.setTristate(True) chk.setCheckState(Qt.PartiallyChecked) chk3 = QCheckBox('checked') chk3.setChecked(True) hbox.addWidget(QCheckBox('unchecked')) hbox.addWidget(chk) hbox.addWidget(chk3) lay.addLayout(hbox) lay.addWidget(TabDemo(emphasized=emphasized)) sld = QSlider(Qt.Horizontal) sld.setValue(50) lay.addWidget(sld) scroll = QScrollBar(Qt.Horizontal) scroll.setValue(50) lay.addWidget(scroll) lay.addWidget(QHRangeSlider(parent=self)) text = QTextEdit() text.setMaximumHeight(100) text.setHtml(blurb) lay.addWidget(text) lay.addWidget(QTimeEdit()) edit = QLineEdit() edit.setPlaceholderText('LineEdit placeholder...') lay.addWidget(edit) lay.addWidget(QLabel('label')) prog = QProgressBar() prog.setValue(50) lay.addWidget(prog) groupBox = QGroupBox("Exclusive Radio Buttons") radio1 = QRadioButton("&Radio button 1") radio2 = QRadioButton("R&adio button 2") radio3 = QRadioButton("Ra&dio button 3") radio1.setChecked(True) hbox = QHBoxLayout() hbox.addWidget(radio1) hbox.addWidget(radio2) hbox.addWidget(radio3) hbox.addStretch(1) groupBox.setLayout(hbox) lay.addWidget(groupBox)
def _setupUi(self): # selection widgets self.rb_interp = QRadioButton('Interpolate') self.rb_confsrv = QRadioButton('Take value from Config Server') self.rb_create = QRadioButton('Create from template') # data widget self.config_data = QWidget() glay_data = QGridLayout(self.config_data) self.le_interp_label = QLineEdit(self) # interpolate self.le_confsrv_name = _ConfigLineEdit( parent=self, config_type='bo_normalized') # from ConfigDB self.le_confsrv_name.textChanged.connect( self._handleInsertExistingConfig) self.le_confsrv_name.setVisible(False) self.le_nominal_label = QLineEdit(self) # from template self.le_nominal_label.setVisible(False) self.sb_time = QDoubleSpinBoxPlus(self) self.sb_time.setMaximum(490) self.sb_time.setDecimals(3) self.bt_insert = QPushButton('Insert', self) self.bt_insert.setAutoDefault(False) self.bt_insert.setDefault(False) self.bt_insert.clicked.connect(self._emitConfigData) self.bt_cancel = QPushButton('Cancel', self) self.bt_cancel.setAutoDefault(False) self.bt_cancel.setDefault(False) self.bt_cancel.clicked.connect(self.close) glay_data.addWidget(QLabel('Label: ', self), 0, 0) glay_data.addWidget(self.le_interp_label, 0, 1) glay_data.addWidget(self.le_confsrv_name, 0, 1) glay_data.addWidget(self.le_nominal_label, 0, 1) glay_data.addWidget(QLabel('Time [ms]: ', self), 1, 0) glay_data.addWidget(self.sb_time, 1, 1) glay_data.addWidget(self.bt_cancel, 2, 0) glay_data.addWidget(self.bt_insert, 2, 1) # connect visibility signals self.rb_interp.toggled.connect(self.le_interp_label.setVisible) self.rb_interp.setChecked(True) self.rb_confsrv.toggled.connect(self.le_confsrv_name.setVisible) self.rb_create.toggled.connect(self.le_nominal_label.setVisible) # layout lay = QVBoxLayout() lay.addWidget(QLabel('<h4>Insert a Normalized Configuration</h4>', self), alignment=Qt.AlignCenter) lay.addWidget(self.rb_interp) lay.addWidget(self.rb_confsrv) lay.addWidget(self.rb_create) lay.addStretch() lay.addWidget(self.config_data) self.setLayout(lay)
def __init__(self, *, gpc, gui_vars): super().__init__() # Global processing classes self.gpc = gpc # Global GUI variables (used for control of GUI state) self.gui_vars = gui_vars self.cb_plot_type = QComboBox() self.cb_plot_type.addItems(["LinLog", "Linear"]) self.cb_plot_type.setCurrentIndex(self.gpc.get_preview_plot_type()) self.cb_plot_type.currentIndexChanged.connect(self.cb_plot_type_current_index_changed) self.rb_selected_region = QRadioButton("Selected region") self.rb_selected_region.setChecked(True) self.rb_full_spectrum = QRadioButton("Full spectrum") if self.gpc.get_preview_energy_range() == EnergyRangePresets.SELECTED_RANGE: self.rb_selected_region.setChecked(True) elif self.gpc.get_preview_energy_range() == EnergyRangePresets.FULL_SPECTRUM: self.rb_full_spectrum.setChecked(True) else: logger.error( "Spectrum preview: incorrect Enum value for energy range was used:\n" " Report the error to the development team." ) self.btn_group_region = QButtonGroup() self.btn_group_region.addButton(self.rb_selected_region) self.btn_group_region.addButton(self.rb_full_spectrum) self.btn_group_region.buttonToggled.connect(self.btn_group_region_button_toggled) self.mpl_canvas = FigureCanvas(self.gpc.plot_model._fig_preview) self.mpl_toolbar = NavigationToolbar(self.mpl_canvas, self) # Keep layout without change when canvas is hidden (invisible) sp_retain = self.mpl_canvas.sizePolicy() sp_retain.setRetainSizeWhenHidden(True) self.mpl_canvas.setSizePolicy(sp_retain) vbox = QVBoxLayout() hbox = QHBoxLayout() hbox.addWidget(self.cb_plot_type) hbox.addStretch(1) hbox.addWidget(self.rb_selected_region) hbox.addWidget(self.rb_full_spectrum) vbox.addLayout(hbox) vbox.addWidget(self.mpl_toolbar) vbox.addWidget(self.mpl_canvas) self.setLayout(vbox) self._set_tooltips()
def __init__(self, config, parent=None): """ Construct a dialog window. Parameters ---------- config : Config Initial configuration parent : QWidget """ super(ConfigDialog, self).__init__(parent) self.setWindowTitle(_('Configure tests')) layout = QVBoxLayout(self) framework_groupbox = QGroupBox(_('Test framework'), self) framework_layout = QVBoxLayout(framework_groupbox) self.pytest_button = QRadioButton('py.test', framework_groupbox) framework_layout.addWidget(self.pytest_button) self.nose_button = QRadioButton('nose', framework_groupbox) framework_layout.addWidget(self.nose_button) layout.addWidget(framework_groupbox) layout.addSpacing(10) wdir_label = QLabel(_('Directory from which to run tests')) layout.addWidget(wdir_label) wdir_layout = QHBoxLayout() self.wdir_lineedit = QLineEdit(self) wdir_layout.addWidget(self.wdir_lineedit) self.wdir_button = QPushButton(ima.icon('DirOpenIcon'), '', self) self.wdir_button.setToolTip(_("Select directory")) self.wdir_button.clicked.connect(lambda: self.select_directory()) wdir_layout.addWidget(self.wdir_button) layout.addLayout(wdir_layout) layout.addSpacing(20) self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) layout.addWidget(self.buttons) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) ok_button = self.buttons.button(QDialogButtonBox.Ok) ok_button.setEnabled(False) self.pytest_button.toggled.connect(lambda: ok_button.setEnabled(True)) self.nose_button.toggled.connect(lambda: ok_button.setEnabled(True)) if config.framework == 'py.test': self.pytest_button.setChecked(True) elif config.framework == 'nose': self.nose_button.setChecked(True) self.wdir_lineedit.setText(config.wdir)
def setupui(self): vbl = QVBoxLayout(self) self.stack = QStackedWidget(self) vbl.addWidget(self.stack) rbA = QRadioButton('Antennas', self) rbP = QRadioButton('Positions', self) rbA.toggled.connect(_part(self.toggle_button, 0)) rbP.toggled.connect(_part(self.toggle_button, 1)) self.radio_buttons.append(rbA) self.radio_buttons.append(rbP) rbA.setChecked(True) hbl = QHBoxLayout() hbl.addStretch() hbl.addWidget(rbA) hbl.addStretch() hbl.addWidget(rbP) hbl.addStretch() vbl.addItem(hbl) # ##### Antennas Widget ###### stack1 = QWidget(self.stack) self.stack.addWidget(stack1) vbl = QVBoxLayout(stack1) graph = self.create_graph(stack1, 'ant') vbl.addWidget(graph) stats = self.create_statistics(stack1, 'ant') vbl.addWidget(stats) # ##### Position and Amplitudes Widget ###### stack2 = QWidget(self.stack) self.stack.addWidget(stack2) vbl = QVBoxLayout(stack2) graph = self.create_graph(stack2, 'pos') vbl.addWidget(graph) graph = self.create_graph(stack2, 'amp') vbl.addWidget(graph) self.setStyleSheet(""" #SinglePassDataGraph{ min-width:48em; min-height:24em; } QLabel{ min-width:6em; max-width:6em; min-height:1.5em; max-height:1.5em; }""")
def initialize_widget(self): if self.is_radio: for button in self._buttons: button.toggled.disconnect(self.index_changed) self.vbox.removeWidget(button) button.deleteLater() self._buttons = [] else: self.combobox.blockSignals(True) while self.combobox.count(): self.combobox.removeItem(0) _choices = self.item.get_prop_value("data", "choices") for key, lbl, img in _choices: if self.is_radio: button = QRadioButton(lbl, self.group) if img: if is_text_string(img): if not osp.isfile(img): img = get_image_file_path(img) img = QIcon(img) elif isinstance(img, collections.Callable): img = img(key) if self.is_radio: button.setIcon(img) else: self.combobox.addItem(img, lbl) elif not self.is_radio: self.combobox.addItem(lbl) if self.is_radio: self._buttons.append(button) self.vbox.addWidget(button) button.toggled.connect(self.index_changed) if not self.is_radio: self.combobox.blockSignals(False)
def __init__(self, name: str, label: list, removable, parent=None): super().__init__(parent) self.label = label self.name = name self.removable = removable self.radio_btn = QRadioButton() self.label_show = _LabelShow(np.array(label, dtype=np.uint8)) self.remove_btn = QToolButton() self.remove_btn.setIcon(_icon_selector.close_icon) self.edit_btn = QToolButton() self.edit_btn.setIcon(_icon_selector.edit_icon) if removable: self.remove_btn.setToolTip("Remove colormap") else: self.remove_btn.setToolTip("This colormap is protected") self.edit_btn.setToolTip("Create new label schema base on this") layout = QHBoxLayout() layout.addWidget(self.radio_btn) layout.addWidget(self.label_show, 1) layout.addWidget(self.remove_btn) layout.addWidget(self.edit_btn) self.remove_btn.setEnabled(removable) self.setLayout(layout) self.remove_btn.clicked.connect(self.remove_fun) self.edit_btn.clicked.connect(self.edit_fun) self.radio_btn.clicked.connect(self.selected_fun)
def create_radiobutton(self, text, option, default=NoDefault, tip=None, msg_warning=None, msg_info=None, msg_if_enabled=False, button_group=None, restart=False, section=None): radiobutton = QRadioButton(text) if button_group is None: if self.default_button_group is None: self.default_button_group = QButtonGroup(self) button_group = self.default_button_group button_group.addButton(radiobutton) if tip is not None: radiobutton.setToolTip(tip) self.radiobuttons[radiobutton] = (section, option, default) if msg_warning is not None or msg_info is not None: def show_message(is_checked): if is_checked or not msg_if_enabled: if msg_warning is not None: QMessageBox.warning(self, self.get_name(), msg_warning, QMessageBox.Ok) if msg_info is not None: QMessageBox.information(self, self.get_name(), msg_info, QMessageBox.Ok) radiobutton.toggled.connect(show_message) radiobutton.restart_required = restart radiobutton.label_text = text return radiobutton
def setup_page(self): lbl_select = QLabel(_('Select method:')) self.rb_new = QRadioButton(_('Create a new project')) self.rb_old = QRadioButton(_('Open an existing project')) hbox = QHBoxLayout() hbox.addWidget(self.rb_new) hbox.addWidget(self.rb_old) self.layout.addWidget(lbl_select) self.layout.addLayout(hbox) self.new_group = QGroupBox(_("New project")) self.new_project_name = self.create_lineedit("Project name", alignment=Qt.Horizontal) self.new_project_name.edit.setText(_("test")) self.new_project_path = self.create_browsedir("Project path") self.new_project_path.lineedit.edit.setText(os.getcwd()) new_layout = QVBoxLayout() new_layout.addWidget(self.new_project_name) new_layout.addWidget(self.new_project_path) self.new_group.setLayout(new_layout) self.old_group = QGroupBox(_("Existing project")) self.old_project_name = self.create_browsefile( "Project name", filters="EZD files (*.ezd);;All Files (*)") text = os.path.join(os.getcwd(), 'fake.ezd') self.old_project_name.lineedit.edit.setText(text) old_layout = QVBoxLayout() old_layout.addWidget(self.old_project_name) self.old_group.setLayout(old_layout) btnApply = QPushButton(_('Next')) btnApply.clicked.connect(self.apply) btnClose = QPushButton(_('Exit')) btnClose.clicked.connect(self.stop) hbox = QHBoxLayout() hbox.addWidget(btnApply) hbox.addWidget(btnClose) self.layout.addWidget(self.new_group) self.layout.addWidget(self.old_group) self.layout.addLayout(hbox) self.rb_new.toggled.connect(self.toggle) self.rb_old.toggled.connect(self.toggle) self.rb_old.setChecked(True)
def setup_ui(self): """Initialize widgets.""" info_label = QLabel() info_label.setText("Hit enter to capture your image!") self.image_label = QLabel() self.image_label.setMinimumSize(320, 240) self.image_label.setScaledContents(True) button_layout = QVBoxLayout() button_layout.setAlignment(Qt.AlignLeft) self.style_buttons = [ QRadioButton(settings.STYLE_SHORTCUTS[i] + ". " + style.name if i < len(settings.STYLE_SHORTCUTS) else style.name) for i, style in enumerate(self.styles) ] self.style_buttons[self.styles.index( self.selected_style)].setChecked(True) self.style_button_group = QButtonGroup() for i, btn in enumerate(self.style_buttons): button_layout.addWidget(btn) self.style_button_group.addButton(btn, i) btn.clicked.connect( partial(lambda style: self.style_button_clicked(style), self.styles[i])) button_layout.addStretch(1) ctrl_layout = QHBoxLayout() if not settings.KIOSK: fullscreen_button = QPushButton('[ ]') fullscreen_button.setMaximumWidth( fullscreen_button.fontMetrics().boundingRect('[ ]').width() + 10) fullscreen_button.clicked.connect(self.toggle_fullscreen) ctrl_layout.addWidget(fullscreen_button) ctrl_layout.addStretch(1) self.size_combo = QComboBox() for s in settings.SIZES: self.size_combo.addItem(s) self.size_combo.setCurrentIndex(settings.SIZES.index(self.quality)) ctrl_layout.addWidget(self.size_combo) self.size_combo.activated[str].connect(self.quality_choice) button_layout.addLayout(ctrl_layout) sub_layout = QHBoxLayout() sub_layout.addLayout(button_layout) sub_layout.addWidget(self.image_label, 1) main_layout = QVBoxLayout() main_layout.addWidget(info_label) main_layout.addLayout(sub_layout) self.setLayout(main_layout)
def showListOfCollections(self): self.collectionsList.clear() if len(config.bibleCollections) > 0: for collection in sorted(config.bibleCollections.keys()): showBibleSelection = QRadioButton() showBibleSelection.setChecked(False) self.collectionsList.itemClicked.connect(self.selectCollection) self.collectionsList.addItem(collection) else: self.collectionsList.addItem("[No collection defined]")
def createTopLeftGroupBox(self): self.topLeftGroupBox = QGroupBox("Group 1") radioButton1 = QRadioButton("Radio button 1") radioButton2 = QRadioButton("Radio button 2") radioButton3 = QRadioButton("Radio button 3") radioButton1.setChecked(True) checkBox = QCheckBox("Tri-state check box") checkBox.setTristate(True) checkBox.setCheckState(Qt.PartiallyChecked) layout = QVBoxLayout() layout.addWidget(radioButton1) layout.addWidget(radioButton2) layout.addWidget(radioButton3) layout.addWidget(checkBox) layout.addStretch(1) self.topLeftGroupBox.setLayout(layout)
def _setup_rgb_element(self, n_row, *, rb_check=0): """ Parameters ---------- rb_check: int The number of QRadioButton to check. Typically this would be the row number. """ combo_elements = ComboBoxNamed(name=f"{n_row}") # combo_elements.setSizeAdjustPolicy(QComboBox.AdjustToContents) # Set text color for QComboBox widget (necessary if the program is used with Dark theme) pal = combo_elements.palette() pal.setColor(QPalette.ButtonText, Qt.black) combo_elements.setPalette(pal) # Set text color for drop-down view (necessary if the program is used with Dark theme) pal = combo_elements.view().palette() pal.setColor(QPalette.Text, Qt.black) combo_elements.view().setPalette(pal) btns = [QRadioButton(), QRadioButton(), QRadioButton()] if 0 <= rb_check < len(btns): btns[rb_check].setChecked(True) # Color is set for operation with Dark theme for btn in btns: pal = btn.palette() pal.setColor(QPalette.Text, Qt.black) btn.setPalette(pal) btn_group = QButtonGroup() for btn in btns: btn_group.addButton(btn) rng = RangeManager(name=f"{n_row}", add_sliders=True) rng.setTextColor([0, 0, 0]) # Set text color to 'black' # Set some text in edit boxes (just to demonstrate how the controls will look like) rng.le_min_value.setText("0.0") rng.le_max_value.setText("1.0") rng.setAlignment(Qt.AlignCenter) return combo_elements, btns, rng, btn_group
def __init__(self, parent): super().__init__(parent) self.setWindowTitle("Set reference") vbox = QVBoxLayout(self) grid = QGridLayout() self.average = QRadioButton("Average") self.channels = QRadioButton("Channel(s):") self.average.toggled.connect(self.toggle) self.channellist = QLineEdit() self.channellist.setEnabled(False) self.average.setChecked(True) grid.addWidget(self.average, 0, 0) grid.addWidget(self.channels, 1, 0) grid.addWidget(self.channellist, 1, 1) vbox.addLayout(grid) buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(buttonbox) buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) vbox.setSizeConstraint(QVBoxLayout.SetFixedSize)
def setup_button(self, enabled: bool, selected: bool) -> None: """ The button will be disabled but still shown if `enabled` is false. """ self.button = QRadioButton("USE" if enabled else "Not Installed") self.button.setEnabled(enabled) self.button.setChecked(selected) font = Fonts.text font.setItalic(True) self.button.setFont(font) self.layout.addWidget(self.button)
def create_control_panel(self): # Create control panel # +/- range cntrl_layout = QHBoxLayout() cntrl_layout.addWidget(QLabel("+/-")) self.range_edit = QLineEdit("{:.2f}".format(YRANGE)) self.range_edit.editingFinished.connect( self.on_range_edit_editingFinished) cntrl_layout.addWidget(self.range_edit) # buttons for audio monitoring cntrl_layout.addStretch(1) cntrl_layout.addWidget(QLabel("Monitor: ")) monitor_group = QButtonGroup(parent=self) none_button = QRadioButton("None") none_button.setChecked(True) monitor_group.addButton(none_button) monitor_group.setId(none_button, 0) cntrl_layout.addWidget(none_button) for chan_ix in range(len(self.group_info)): new_button = QRadioButton(self.group_info[chan_ix]['label']) monitor_group.addButton(new_button) monitor_group.setId(new_button, chan_ix + 1) cntrl_layout.addWidget(new_button) monitor_group.buttonClicked[int].connect(self.on_monitor_group_clicked) # Checkbox for HP filter filter_checkbox = QCheckBox("HP") filter_checkbox.stateChanged.connect(self.on_hp_filter_changed) filter_checkbox.setChecked(True) cntrl_layout.addWidget(filter_checkbox) # Checkbox for Comb filter filter_checkbox = QCheckBox("LN") filter_checkbox.setEnabled(False) filter_checkbox.stateChanged.connect(self.on_ln_filter_changed) filter_checkbox.setChecked(False) cntrl_layout.addWidget(filter_checkbox) # Finish self.layout().addLayout(cntrl_layout)
def __init__(self, parent): super(TaskOptionsGroupBox, self).__init__(parent) self.widget_layout = QFormLayout(self) self.setLayout(self.widget_layout) self.setTitle("Time") self.time_label = QLabel(self) self.time_label.setText("Execute: ") self.time_now = QRadioButton(self) self.time_now.setText("Immediately") self.time_now.setChecked(True) self.time_schedule = QRadioButton(self) self.time_schedule.setText("Schedule") self.schedule_select = QDateTimeEdit(self) self.schedule_select.setDateTime(QDateTime.currentDateTime()) self.schedule_select.setEnabled(False) self.user_activity_label = QLabel(self) self.user_activity_label.setText("User activity") self.user_activity_combo = QComboBox(self) self.user_activity_combo.addItems([ "0 - Disabled", "1 - Low", "2 - Normal", "3 - Medium", "4 - High", "5 - Very high" ]) self.widget_layout.addRow(self.time_label, None) self.widget_layout.addRow(self.time_now, None) self.widget_layout.addRow(self.time_schedule, self.schedule_select) self.widget_layout.addRow(self.user_activity_label, self.user_activity_combo) self.time_schedule.toggled.connect(self.on_time_schedule_toggled)
def __init__(self, parent: MainWindowBase) -> None: """Reference names: + Iteration collections. + Result data. + Main window function references. """ super(DimensionalSynthesis, self).__init__(parent) self.setupUi(self) self.mech: Dict[str, Any] = {} self.path: Dict[int, List[_Coord]] = {} # Some reference of 'collections' self.collections = parent.collections.configure_widget.collections self.get_collection = parent.get_configure self.input_from = parent.input_from self.output_to = parent.output_to self.save_reply_box = parent.save_reply_box self.project_no_save = parent.project_no_save self.merge_result = parent.merge_result self.update_ranges = parent.main_canvas.update_ranges self.set_solving_path = parent.main_canvas.set_solving_path self.get_zoom = parent.main_canvas.get_zoom self.prefer = parent.prefer # Data and functions self.mechanism_data: List[Dict[str, Any]] = [] self.alg_options: Dict[str, Union[int, float]] = {} self.alg_options.update(DEFAULT_PARAMS) self.alg_options.update(PARAMS[AlgorithmType.DE]) # Canvas self.preview_canvas = PreviewCanvas(self) self.preview_layout.addWidget(self.preview_canvas) # Splitter self.main_splitter.setStretchFactor(0, 10) self.main_splitter.setStretchFactor(1, 100) self.up_splitter.setSizes([80, 100]) self.down_splitter.setSizes([20, 80]) # Table widget column width header = self.parameter_list.horizontalHeader() header.setSectionResizeMode(QHeaderView.ResizeToContents) self.algorithm_options: Dict[AlgorithmType, QRadioButton] = {} for option in PARAMS: button = QRadioButton(option.value, self) button.clicked.connect(self.__set_algorithm_default) self.algorithm_options[option] = button self.algorithm_layout.addWidget(button) self.clear()
def __init__(self, parent: MainWindowBase): """Reference names: + Iteration collections. + Result data. + Main window function references. """ super(Optimizer, self).__init__(parent) self.setupUi(self) self.mech = {} self.path = {} # Some reference of 'collections' self.collections = parent.collections.configure_widget.collections self.get_collection = parent.get_configure self.input_from = parent.input_from self.output_to = parent.output_to self.save_reply_box = parent.save_reply_box self.project_no_save = parent.project_no_save self.merge_result = parent.merge_result self.update_ranges = parent.main_canvas.update_ranges self.set_solving_path = parent.main_canvas.set_solving_path self.get_zoom = parent.main_canvas.get_zoom self.prefer = parent.prefer # Data and functions self.mechanism_data = [] self.alg_options = default(AlgorithmType.DE) # Canvas self.preview_canvas = PreviewCanvas(self) self.preview_layout.addWidget(self.preview_canvas) # Splitter self.main_splitter.setStretchFactor(0, 10) self.main_splitter.setStretchFactor(1, 100) self.canvas_splitter.setSizes([80, 100]) self.down_splitter.setSizes([20, 80]) # Table widget column width header = self.parameter_list.horizontalHeader() header.setSectionResizeMode(QHeaderView.ResizeToContents) self.algorithm_options = {} for opt in AlgorithmType: button = QRadioButton(opt.value, self) button.clicked.connect(self.__set_algorithm_default) self.algorithm_options[opt] = button self.algorithm_layout.addWidget(button) self.clear()
def _dock_add_radio_buttons(self, value, rng, callback, *, vertical=True, layout=None): layout = self._dock_layout if layout is None else layout group_layout = QVBoxLayout() if vertical else QHBoxLayout() group = QButtonGroup() for val in rng: button = QRadioButton(val) if val == value: button.setChecked(True) group.addButton(button) self._layout_add_widget(group_layout, button) def func(button): callback(button.text()) group.buttonClicked.connect(func) self._layout_add_widget(layout, group_layout) return _QtWidgetList(group)
def create_widgets(self): """creates the menu objects""" # Name self.name = QLabel("Title:") self.name_edit = QLineEdit(str(self._default_name)) self.name_button = QPushButton("Default") # Min self.min = QLabel("Min:") self.min_edit = QLineEdit(str(self._default_min)) self.min_button = QPushButton("Default") # Max self.max = QLabel("Max:") self.max_edit = QLineEdit(str(self._default_max)) self.max_button = QPushButton("Default") #--------------------------------------- # Format self.format = QLabel("Format (e.g. %.3f, %g, %.6e):") self.format_edit = QLineEdit(str(self._format)) self.format_button = QPushButton("Default") #--------------------------------------- # Scale self.scale = QLabel("Scale:") self.scale_edit = QLineEdit(str(self._scale)) self.scale_button = QPushButton("Default") if self._default_scale == 0.0: self.scale.setVisible(False) self.scale_edit.setVisible(False) self.scale_button.setVisible(False) # Phase self.phase = QLabel("Phase (deg):") self.phase_edit = QLineEdit(str(self._phase)) self.phase_button = QPushButton("Default") if self._default_phase is None: self.phase.setVisible(False) self.phase_edit.setVisible(False) self.phase_button.setVisible(False) self.phase_edit.setText('0.0') #tip = QtGui.QToolTip() #tip.setTe #self.format_edit.toolTip(tip) #--------------------------------------- # nlabels self.nlabels = QLabel("Number of Labels:") self.nlabels_edit = QLineEdit(str(self._nlabels)) self.nlabels_button = QPushButton("Default") self.labelsize = QLabel("Label Size:") self.labelsize_edit = QLineEdit(str(self._labelsize)) self.labelsize_button = QPushButton("Default") self.ncolors = QLabel("Number of Colors:") self.ncolors_edit = QLineEdit(str(self._ncolors)) self.ncolors_button = QPushButton("Default") self.colormap = QLabel("Color Map:") self.colormap_edit = QComboBox(self) self.colormap_button = QPushButton("Default") for key in colormap_keys: self.colormap_edit.addItem(key) self.colormap_edit.setCurrentIndex(colormap_keys.index(self._colormap)) # -------------------------------------------------------------- # the header self.grid2_title = QLabel("Color Scale:") # red/blue or blue/red self.low_to_high_radio = QRadioButton('Low -> High') self.high_to_low_radio = QRadioButton('High -> Low') widget = QWidget(self) low_to_high_group = QButtonGroup(widget) low_to_high_group.addButton(self.low_to_high_radio) low_to_high_group.addButton(self.high_to_low_radio) self.low_to_high_radio.setChecked(self._default_is_low_to_high) self.high_to_low_radio.setChecked(not self._default_is_low_to_high) # horizontal / vertical self.horizontal_radio = QRadioButton("Horizontal") self.vertical_radio = QRadioButton("Vertical") widget = QWidget(self) horizontal_vertical_group = QButtonGroup(widget) horizontal_vertical_group.addButton(self.horizontal_radio) horizontal_vertical_group.addButton(self.vertical_radio) self.horizontal_radio.setChecked(self._default_is_horizontal) self.vertical_radio.setChecked(not self._default_is_horizontal) # on / off self.show_radio = QRadioButton("Show") self.hide_radio = QRadioButton("Hide") widget = QWidget(self) show_hide_group = QButtonGroup(widget) show_hide_group.addButton(self.show_radio) show_hide_group.addButton(self.hide_radio) self.show_radio.setChecked(self._default_is_shown) self.hide_radio.setChecked(not self._default_is_shown) # -------------------------------------------------------------- if self._is_normals: self.max.hide() self.min.hide() self.max_edit.hide() self.min_edit.hide() self.max_button.hide() self.min_button.hide() self.format.hide() self.format_edit.hide() self.format_button.hide() self.nlabels.hide() self.nlabels_edit.hide() self.nlabels_button.hide() self.ncolors.hide() self.ncolors_edit.hide() self.ncolors_button.hide() self.grid2_title.hide() self.vertical_radio.hide() self.horizontal_radio.hide() self.show_radio.hide() self.hide_radio.hide() self.low_to_high_radio.hide() self.high_to_low_radio.hide() self.colormap.hide() self.colormap_edit.hide() self.colormap_button.hide() self.animate_button = QPushButton('Create Animation') if self._default_scale == 0.0: self.animate_button.setEnabled(False) self.animate_button.setToolTip( 'This must be a displacement-like result to animate') # closing self.apply_button = QPushButton("Apply") self.ok_button = QPushButton("OK") self.cancel_button = QPushButton("Cancel")
def __init__(self, parent, search_text, search_text_regexp, search_path, exclude, exclude_idx, exclude_regexp, supported_encodings, in_python_path, more_options): QWidget.__init__(self, parent) if search_path is None: search_path = getcwd() self.path = '' self.project_path = None self.file_path = None if not isinstance(search_text, (list, tuple)): search_text = [search_text] if not isinstance(search_path, (list, tuple)): search_path = [search_path] if not isinstance(exclude, (list, tuple)): exclude = [exclude] self.supported_encodings = supported_encodings # Layout 1 hlayout1 = QHBoxLayout() self.search_text = PatternComboBox(self, search_text, _("Search pattern")) self.edit_regexp = create_toolbutton(self, icon=ima.icon('advanced'), tip=_('Regular expression')) self.edit_regexp.setCheckable(True) self.edit_regexp.setChecked(search_text_regexp) self.more_widgets = () self.more_options = create_toolbutton(self, toggled=self.toggle_more_options) self.more_options.setCheckable(True) self.more_options.setChecked(more_options) self.ok_button = create_toolbutton(self, text=_("Search"), icon=ima.icon('find'), triggered=lambda: self.find.emit(), tip=_("Start search"), text_beside_icon=True) self.ok_button.clicked.connect(self.update_combos) self.stop_button = create_toolbutton( self, text=_("Stop"), icon=ima.icon('editclear'), triggered=lambda: self.stop.emit(), tip=_("Stop search"), text_beside_icon=True) self.stop_button.setEnabled(False) for widget in [ self.search_text, self.edit_regexp, self.ok_button, self.stop_button, self.more_options ]: hlayout1.addWidget(widget) # Layout 2 hlayout2 = QHBoxLayout() self.exclude_pattern = PatternComboBox(self, exclude, _("Excluded filenames pattern")) if exclude_idx is not None and exclude_idx >= 0 \ and exclude_idx < self.exclude_pattern.count(): self.exclude_pattern.setCurrentIndex(exclude_idx) self.exclude_regexp = create_toolbutton(self, icon=ima.icon('advanced'), tip=_('Regular expression')) self.exclude_regexp.setCheckable(True) self.exclude_regexp.setChecked(exclude_regexp) exclude_label = QLabel(_("Exclude:")) exclude_label.setBuddy(self.exclude_pattern) for widget in [ exclude_label, self.exclude_pattern, self.exclude_regexp ]: hlayout2.addWidget(widget) # Layout 3 hlayout3 = QHBoxLayout() self.global_path_search = QRadioButton( _("Current working " "directory"), self) self.global_path_search.setChecked(True) self.global_path_search.setToolTip( _("Search in all files and " "directories present on the" "current Spyder path")) self.project_search = QRadioButton(_("Project"), self) self.project_search.setToolTip( _("Search in all files and " "directories present on the" "current project path (If opened)")) self.project_search.setEnabled(False) self.file_search = QRadioButton(_("File"), self) self.file_search.setToolTip(_("Search in current opened file")) for wid in [ self.global_path_search, self.project_search, self.file_search ]: hlayout3.addWidget(wid) hlayout3.addStretch(1) self.search_text.valid.connect(lambda valid: self.find.emit()) self.exclude_pattern.valid.connect(lambda valid: self.find.emit()) vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) vlayout.addLayout(hlayout1) vlayout.addLayout(hlayout2) vlayout.addLayout(hlayout3) self.more_widgets = (hlayout2, ) self.toggle_more_options(more_options) self.setLayout(vlayout) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
def add_reader_buttons(self, layout, readers): """Add radio button to layout for each reader in readers""" for display_name in sorted(readers): button = QRadioButton(f"{display_name}") self.reader_btn_group.addButton(button) layout.addWidget(button)
def create_widgets(self): """creates the menu objects""" self.box_scale = QGroupBox('Animate Scale') self.box_time = QGroupBox('Animate Time') icase_max = 1000 # TODO: update 1000 self.checkbox_fringe = QCheckBox('Animate') self.checkbox_fringe.setToolTip( 'Animate the fringe in addition to the deflection') #self.checkbox_disp = QCheckBox('Animate') self.checkbox_fringe.setEnabled(False) self.icase_fringe_label = QLabel("iCase (Fringe):") self.icase_fringe_edit = QSpinBox(self) self.icase_fringe_edit.setRange(0, icase_max) self.icase_fringe_edit.setSingleStep(1) if self._icase_fringe is not None: self.icase_fringe_edit.setValue(self._icase_fringe) self.icase_fringe_edit.setToolTip( 'Case Number for the Scale/Phase Animation Type.\n' 'Defaults to the result you had shown when you clicked "Create Animation".\n' 'iCase can be seen by clicking "Apply" on a result.') self.icase_disp_label = QLabel("iCase (Disp):") self.icase_disp_edit = QSpinBox(self) self.icase_disp_edit.setRange(1, icase_max) self.icase_disp_edit.setSingleStep(1) if self._icase_disp is not None: self.icase_disp_edit.setValue(self._icase_disp) self.checkbox_vector = QCheckBox('Animate') self.checkbox_vector.setToolTip( 'Animate the vector in addition to the deflection') self.checkbox_vector.hide() #self.checkbox_disp = QCheckBox('Animate') self.icase_vector_label = QLabel("iCase (Vector):") self.icase_vector_edit = QSpinBox(self) self.icase_vector_edit.setRange(1, icase_max) self.icase_vector_edit.setSingleStep(1) if self._icase_vector is not None: self.icase_vector_edit.setValue(self._icase_vector) self.scale_label = QLabel("True Scale:") self.scale_edit = QLineEdit(str(self._scale)) self.scale_button = QPushButton("Default") self.scale_edit.setToolTip('Scale factor of the "deflection"') self.scale_button.setToolTip('Sets the scale factor of the gif to %s' % self._scale) self.arrow_scale_label = QLabel("Arrow Scale:") self.arrow_scale_edit = QLineEdit(str(self._scale)) self.arrow_scale_button = QPushButton("Default") self.arrow_scale_edit.setToolTip('Scale factor of the "arrows"') self.arrow_scale_button.setToolTip( 'Sets the arrow scale factor of the gif to %s' % self._arrow_scale) self.arrow_scale_label.setVisible(False) self.arrow_scale_edit.setVisible(False) self.arrow_scale_button.setVisible(False) self.time_label = QLabel("Total Time (sec):") self.time_edit = QDoubleSpinBox(self) self.time_edit.setValue(self._default_time) self.time_edit.setRange(0.1, 5. * 60.) self.time_edit.setDecimals(2) self.time_edit.setSingleStep(0.1) self.time_button = QPushButton("Default") self.time_edit.setToolTip("Total time of the gif") self.time_button.setToolTip('Sets the total time of the gif to %.2f' % self._default_time) self.fps_label = QLabel("Frames/Second:") self.fps_edit = QSpinBox(self) self.fps_edit.setRange(1, 60) self.fps_edit.setSingleStep(1) self.fps_edit.setValue(self._default_fps) self.fps_button = QPushButton("Default") self.fps_edit.setToolTip( "A higher FPS is smoother, but may not play well for large gifs") self.fps_button.setToolTip('Sets the FPS to %s' % self._default_fps) self.resolution_label = QLabel("Resolution Scale:") self.resolution_edit = QSpinBox(self) self.resolution_edit.setRange(1, 5) self.resolution_edit.setSingleStep(1) self.resolution_edit.setValue(self._default_resolution) self.resolution_button = QPushButton("Default") self.resolution_edit.setToolTip( 'Scales the window resolution by an integer factor') self.resolution_button.setToolTip('Sets the resolution to %s' % self._default_resolution) #----------------- # Time plot self.fringe_label = QLabel("Fringe") self.icase_fringe_start_edit = QSpinBox(self) self.icase_fringe_start_edit.setRange(0, icase_max) self.icase_fringe_start_edit.setSingleStep(1) self.icase_fringe_start_edit.setValue(self._icase_fringe) self.icase_fringe_start_button = QPushButton("Default") self.icase_fringe_end_edit = QSpinBox(self) self.icase_fringe_end_edit.setRange(0, icase_max) self.icase_fringe_end_edit.setSingleStep(1) self.icase_fringe_end_edit.setValue(self._icase_fringe) self.icase_fringe_end_button = QPushButton("Default") self.icase_fringe_delta_edit = QSpinBox(self) self.icase_fringe_delta_edit.setRange(1, icase_max) self.icase_fringe_delta_edit.setSingleStep(1) self.icase_fringe_delta_edit.setValue(1) self.icase_fringe_delta_button = QPushButton("Default") self.displacement_label = QLabel("Displacement") self.icase_start = QLabel("iCase Start:") self.icase_disp_start_edit = QSpinBox(self) self.icase_disp_start_edit.setRange(0, icase_max) self.icase_disp_start_edit.setSingleStep(1) self.icase_disp_start_edit.setValue(self._icase_fringe) self.icase_disp_start_button = QPushButton("Default") self.icase_end_label = QLabel("iCase End:") self.icase_disp_end_edit = QSpinBox(self) self.icase_disp_end_edit.setRange(0, icase_max) self.icase_disp_end_edit.setSingleStep(1) self.icase_disp_end_edit.setValue(self._icase_fringe) self.icase_disp_end_button = QPushButton("Default") self.icase_delta_label = QLabel("iCase Delta:") self.icase_disp_delta_edit = QSpinBox(self) self.icase_disp_delta_edit.setRange(1, icase_max) self.icase_disp_delta_edit.setSingleStep(1) self.icase_disp_delta_edit.setValue(1) self.icase_disp_delta_button = QPushButton("Default") self.min_value_enable = QCheckBox() self.min_value_label = QLabel("Min Value:") self.min_value_edit = QLineEdit('') #self.min_value_edit.setRange(1, 1000) #self.min_value_edit.setSingleStep(1) #self.min_value_edit.setValue(1) self.min_value_button = QPushButton("Default") self.max_value_enable = QCheckBox() self.max_value_label = QLabel("Max Value:") self.max_value_edit = QLineEdit('') #self.min_value_edit.setRange(1, 1000) # TODO: update 1000 #self.min_value_edit.setSingleStep(1) #self.min_value_edit.setValue(1) self.max_value_button = QPushButton("Default") # TODO: enable this (uncomment) ------------------------------------------ #self.min_value_enable.hide() #self.min_value.hide() #self.min_value_edit.hide() #self.min_value_button.hide() #self.max_value_enable.hide() #self.max_value.hide() #self.max_value_edit.hide() #self.max_value_button.hide() # TODO: enable this (uncomment) ------------------------------------------ self.icase_disp_start_edit.setToolTip( 'The first frame of the animation') self.icase_disp_end_edit.setToolTip( 'The last frame of the animation\n' 'Assumes icase_start + nframes * icase_delta = icase_end') self.icase_disp_delta_edit.setToolTip( 'The frame step size (to skip non-consecutive results).\n' 'Frame skipping can be used to:\n' " - skip across results that you don't want to plot\n" ' - adjust the FPS') self.min_value_edit.setToolTip( 'Min value of the legend (not supported)') self.max_value_edit.setToolTip( 'Max value of the legend (not supported)') #'time' : 0., #'default_time' : 0, #'icase_start' : 10, #'icase_delta' : 3, #'min_value' : 0., #'max_value' : 1000., self.browse_folder_label = QLabel('Output Directory:') self.browse_folder_edit = QLineEdit(str(self._default_dirname)) self.browse_folder_button = QPushButton('Browse') self.browse_folder_edit.setToolTip( 'Location to save the png/gif files') self.gif_label = QLabel("Gif Filename:") self.gif_edit = QLineEdit(str(self._default_name + '.gif')) self.gif_button = QPushButton('Default') self.gif_edit.setToolTip('Name of the gif') self.gif_button.setToolTip('Sets the name of the gif to %s.gif' % self._default_name) # scale / phase if 1: # pragma: no cover self.animate_scale_radio = QRadioButton("Animate Scale") self.animate_phase_radio = QRadioButton("Animate Phase") self.animate_time_radio = QRadioButton("Animate Time") self.animate_freq_sweeep_radio = QRadioButton( "Animate Frequency Sweep") self.animate_scale_radio.setToolTip( 'Animates the scale factor based on the "Animation Type"') self.animate_time_radio.setToolTip( 'Animates the time/load/mode step') self.animate_scale_radio.setChecked(self._default_is_scale) self.animate_phase_radio.setChecked(not self._default_is_scale) self.animate_time_radio.setChecked(False) msg = 'Scale : Animates the scale factor based on the "Animation Profile"\n' if self._default_phase is None: self.animate_phase_radio.setDisabled(True) self.animate_phase_radio.setToolTip( 'Animates the phase angle ' '(only for complex results)') msg += 'Phase : Animates the phase angle (only for complex results)\n' else: self.animate_phase_radio.setToolTip("Animates the phase angle") msg += 'Phase : Animates the phase angle\n' msg += ( 'Time : Animates the time/load/mode step\n' 'Freq Sweep : Animates a complex result across a range of frequencies ' '(not supported)\n') self.animate_freq_sweeep_radio.setDisabled(True) self.animate_freq_sweeep_radio.setToolTip( 'Animates a complex result across a range of frequencies (not supported)' ) else: msg = 'Scale : Animates the scale factor based on the "Animation Profile"\n' if self._default_phase is None: #self.animate_phase_radio.setDisabled(True) #self.animate_phase_radio.setToolTip('Animates the phase angle ' #'(only for complex results)') msg += 'Phase : Animates the phase angle (only for complex results)\n' else: #self.animate_phase_radio.setToolTip("Animates the phase angle") msg += 'Phase : Animates the phase angle\n' msg += ( 'Time : Animates the time/load/mode step\n' 'Freq Sweep : Animates a complex result across a range of frequencies ' '(not supported)\n') self.animation_type = QLabel("Animation Type:") animation_type = OrderedDict() #scale_msg = 'Scale\n' #phase_msg = 'Phase\n' #time_msg = 'Time\n' #animation_types = [ #('Animate Scale', scale_msg), #('Animate Phase', phase_msg), #('Animate Time', time_msg), ##'Animate Frequency Sweep' #] if self._phase is not None: self.animation_types.append('Animate Phase') self.animation_types.append('Animate Time') self.animation_profile_label = QLabel("Animation Profile:") self.animation_profile_edit = QComboBox() for animation_profile in ANIMATION_PROFILES: self.animation_profile_edit.addItem(animation_profile) self.animation_profile_edit.setToolTip('The profile for a scaled GIF') self.animation_type_edit = QComboBox() # TODO: add a tooltip for each item for animation_type in self.animation_types: self.animation_type_edit.addItem(animation_type) #self.animation_type_edit.setToolTip('The profile for a scaled GIF') self.animation_type_edit.setToolTip(msg.rstrip()) self.csv_profile_label = QLabel("CSV profile:") self.csv_profile_edit = QLineEdit() self.csv_profile_browse_button = QPushButton('Browse') self.csv_profile_edit.setToolTip( 'The path to the CSV file of (Scale1, Scale2, Scale3, ...)') #widget = QWidget(self) #horizontal_vertical_group = QButtonGroup(widget) #horizontal_vertical_group.addButton(self.animate_scale_radio) #horizontal_vertical_group.addButton(self.animate_phase_radio) #horizontal_vertical_group.addButton(self.animate_time_radio) #horizontal_vertical_group.addButton(self.animate_freq_sweeep_radio) # animate in gui self.animate_in_gui_checkbox = QCheckBox("Animate In GUI?") self.animate_in_gui_checkbox.setChecked(True) # make images self.make_images_checkbox = QCheckBox("Make images?") self.make_images_checkbox.setChecked(True) # make images self.overwrite_images_checkbox = QCheckBox("Overwrite images?") self.overwrite_images_checkbox.setChecked(True) # delete images when finished self.delete_images_checkbox = QCheckBox("Delete images when finished?") self.delete_images_checkbox.setChecked(True) # endless loop self.repeat_checkbox = QCheckBox("Repeat?") self.repeat_checkbox.setChecked(True) self.repeat_checkbox.setToolTip( "Repeating creates an infinitely looping gif") # endless loop self.make_gif_checkbox = QCheckBox("Make Gif?") if IS_IMAGEIO: self.make_gif_checkbox.setChecked(True) else: self.make_gif_checkbox.setChecked(False) self.make_gif_checkbox.setEnabled(False) self.make_gif_checkbox.setToolTip( 'imageio is not available; install it') # bottom buttons self.step_button = QPushButton("Step") self.wipe_button = QPushButton("Wipe Deformed Shape") self.stop_button = QPushButton("Stop") self.run_button = QPushButton("Run") self.step_button.setToolTip( 'Steps through the animation (for testing)') self.wipe_button.setToolTip( 'Removes the existing "deflecton" from the animation') self.stop_button.setToolTip('Stops the animation') self.run_button.setToolTip('Creates the animation') self.step_button.hide() self.wipe_button.hide() self.wipe_button.setEnabled(False) #self.wipe_button.hide() self.stop_button.setEnabled(False) self.cancel_button = QPushButton("Close") #self.set_grid_time(enabled=False) #self.set_grid_scale(enabled=self._default_is_scale) if self._default_phase: self.on_animate_phase(force=True) set_combo_box_text(self.animation_type_edit, 'Animate Phase') else: self.on_animate_scale(force=True)
def __init__(self, parent, text): QWidget.__init__(self, parent) self.text_editor = QTextEdit(self) self.text_editor.setText(text) self.text_editor.setReadOnly(True) # Type frame type_layout = QHBoxLayout() type_label = QLabel(_("Import as")) type_layout.addWidget(type_label) data_btn = QRadioButton(_("data")) data_btn.setChecked(True) self._as_data = True type_layout.addWidget(data_btn) code_btn = QRadioButton(_("code")) self._as_code = False type_layout.addWidget(code_btn) txt_btn = QRadioButton(_("text")) type_layout.addWidget(txt_btn) h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) type_layout.addItem(h_spacer) type_frame = QFrame() type_frame.setLayout(type_layout) # Opts frame grid_layout = QGridLayout() grid_layout.setSpacing(0) col_label = QLabel(_("Column separator:")) grid_layout.addWidget(col_label, 0, 0) col_w = QWidget() col_btn_layout = QHBoxLayout() self.tab_btn = QRadioButton(_("Tab")) self.tab_btn.setChecked(False) col_btn_layout.addWidget(self.tab_btn) self.ws_btn = QRadioButton(_("Whitespace")) self.ws_btn.setChecked(False) col_btn_layout.addWidget(self.ws_btn) other_btn_col = QRadioButton(_("other")) other_btn_col.setChecked(True) col_btn_layout.addWidget(other_btn_col) col_w.setLayout(col_btn_layout) grid_layout.addWidget(col_w, 0, 1) self.line_edt = QLineEdit(",") self.line_edt.setMaximumWidth(30) self.line_edt.setEnabled(True) other_btn_col.toggled.connect(self.line_edt.setEnabled) grid_layout.addWidget(self.line_edt, 0, 2) row_label = QLabel(_("Row separator:")) grid_layout.addWidget(row_label, 1, 0) row_w = QWidget() row_btn_layout = QHBoxLayout() self.eol_btn = QRadioButton(_("EOL")) self.eol_btn.setChecked(True) row_btn_layout.addWidget(self.eol_btn) other_btn_row = QRadioButton(_("other")) row_btn_layout.addWidget(other_btn_row) row_w.setLayout(row_btn_layout) grid_layout.addWidget(row_w, 1, 1) self.line_edt_row = QLineEdit(";") self.line_edt_row.setMaximumWidth(30) self.line_edt_row.setEnabled(False) other_btn_row.toggled.connect(self.line_edt_row.setEnabled) grid_layout.addWidget(self.line_edt_row, 1, 2) grid_layout.setRowMinimumHeight(2, 15) other_group = QGroupBox(_("Additional options")) other_layout = QGridLayout() other_group.setLayout(other_layout) skiprows_label = QLabel(_("Skip rows:")) other_layout.addWidget(skiprows_label, 0, 0) self.skiprows_edt = QLineEdit('0') self.skiprows_edt.setMaximumWidth(30) intvalid = QIntValidator(0, len(to_text_string(text).splitlines()), self.skiprows_edt) self.skiprows_edt.setValidator(intvalid) other_layout.addWidget(self.skiprows_edt, 0, 1) other_layout.setColumnMinimumWidth(2, 5) comments_label = QLabel(_("Comments:")) other_layout.addWidget(comments_label, 0, 3) self.comments_edt = QLineEdit('#') self.comments_edt.setMaximumWidth(30) other_layout.addWidget(self.comments_edt, 0, 4) self.trnsp_box = QCheckBox(_("Transpose")) #self.trnsp_box.setEnabled(False) other_layout.addWidget(self.trnsp_box, 1, 0, 2, 0) grid_layout.addWidget(other_group, 3, 0, 2, 0) opts_frame = QFrame() opts_frame.setLayout(grid_layout) data_btn.toggled.connect(opts_frame.setEnabled) data_btn.toggled.connect(self.set_as_data) code_btn.toggled.connect(self.set_as_code) # self.connect(txt_btn, SIGNAL("toggled(bool)"), # self, SLOT("is_text(bool)")) # Final layout layout = QVBoxLayout() layout.addWidget(type_frame) layout.addWidget(self.text_editor) layout.addWidget(opts_frame) self.setLayout(layout)