def __init__(self, main_window): """The constructor ... :param main_window: an instance of the MainWindow class """ super(DataViewerTab, self).__init__() self.docs = [] self.lay = [] self.project = [] self.stacks = [] self.viewers_loaded = {} self.viewer_current = {} #Display of combobox containing the viewers self.main_window = main_window self.lay = Qt.QVBoxLayout() self.setLayout(self.lay) hlay = Qt.QHBoxLayout() self.lay.addLayout(hlay) hlay.addWidget(Qt.QLabel('use viewer:')) #Combobox will contain the viewers if they are available self.viewers_combo = Qt.QComboBox() self.viewers_combo.setMinimumWidth(150) hlay.addWidget(self.viewers_combo) hlay.addStretch(1) self.viewers_combo.currentIndexChanged.connect(self.change_viewer)
def __init__(self, engine, parent=None): super(SettingsEditor, self).__init__(parent) self.engine = engine layout = Qt.QVBoxLayout() self.setLayout(layout) env_layout = Qt.QHBoxLayout() layout.addLayout(env_layout) env_layout.addWidget(Qt.QLabel('Environment:')) self.environment_combo = Qt.QComboBox() self.environment_combo.setEditable(True) self.environment_combo.setInsertPolicy( Qt.QComboBox.InsertAlphabetically) self.environment_combo.addItem('global') env_layout.addWidget(self.environment_combo) #htab_layout = Qt.QHBoxLayout() self.tab_wid = QVTabWidget() # Qt.QTabWidget() #self.tab_wid.setTabPosition(Qt.QTabWidget.West) layout.addWidget(self.tab_wid) self.module_tabs = {} buttons_layout = Qt.QHBoxLayout() layout.addLayout(buttons_layout) buttons_layout.addStretch(1) ok = Qt.QPushButton('OK') buttons_layout.addWidget(ok) cancel = Qt.QPushButton('Cancel') buttons_layout.addWidget(cancel) ok.clicked.connect(self.accept) cancel.clicked.connect(self.reject) #ok.setDefault(True) self.environment_combo.activated.connect(self.change_environment) self.update_gui()
def preferences(self): '''Preferences for the dataviewer ''' #Get initial config: im_sec = Config().getViewerFramerate() config = Config().getViewerConfig() ref = Config().get_referential() dialog = Qt.QDialog() dialog.setWindowTitle('Preferences') dialog.resize(600, 400) layout = Qt.QVBoxLayout() layout.setContentsMargins(25, 25, 25, 25) dialog.setLayout(layout) #Change Neuro/Radio configuration config_layout = QHBoxLayout() title_config = Qt.QLabel() title_config.setText('Configuration: ') box = Qt.QComboBox() box.addItem('Neuro') box.addItem('Radio') config_layout.addWidget(title_config) config_layout.addWidget(box) if config == 'radio': box.setCurrentIndex(1) #set automatic time frame rate frame_rate_layout = QHBoxLayout() title = Qt.QLabel() title.setText('Automatic time image display:') slider = Qt.QSlider(Qt.Qt.Horizontal) slider.setRange(1, 100) slider.setValue(int(im_sec)) size = QtCore.QSize(180, 15) slider.setMinimumSize(size) slow_label = Qt.QLabel() fast_label = Qt.QLabel() slow_label.setText('slow') fast_label.setText('fast') frame_rate_layout.addWidget(title) frame_rate_layout.addWidget(slow_label) frame_rate_layout.addWidget(slider) frame_rate_layout.addWidget(fast_label) frame_rate_layout.insertSpacing(1, 200) #Change referential ref_layout = QHBoxLayout() title_ref = Qt.QLabel() title_ref.setText('Referential: ') box2 = Qt.QComboBox() box2.addItem('World Coordinates') box2.addItem('Image referential') ref_layout.addWidget(title_ref) ref_layout.addWidget(box2) box2.setCurrentIndex(int(ref)) #Set general vertical layout layout.addLayout(config_layout) layout.addLayout(frame_rate_layout) layout.addLayout(ref_layout) layout.addStretch(1) #Save and cancel buttons hlay = Qt.QHBoxLayout() layout.addLayout(hlay) ok = Qt.QPushButton('Save') hlay.addStretch(1) hlay.addWidget(ok) ok.clicked.connect(dialog.accept) ok.setDefault(True) cancel = Qt.QPushButton('Cancel') hlay.addWidget(cancel) cancel.clicked.connect(dialog.reject) hlay.addStretch(1) res = dialog.exec_() if res == Qt.QDialog.Accepted: new_config = box.currentText().lower() new_ref = box2.currentIndex() #Save Config parameters and reload images #when config and referential have changed Config().setViewerFramerate(slider.value()) Config().setViewerConfig(new_config) Config().set_referential(new_ref) if new_config != config: self.anaviewer.changeConfig(new_config) if new_ref != ref: self.anaviewer.changeRef()
def create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None): """ Create the widget. Parameters ---------- parent: QWidget (mandatory) the parent widget control_name: str (mandatory) the name of the control we want to create control_value: str (mandatory) the default control value, here the enum values trait: Tait (mandatory) the trait associated to the control label_class: Qt widget class (optional, default: None) the label widget will be an instance of this class. Its constructor will be called using 2 arguments: the label string and the parent widget. Returns ------- out: 2-uplet a two element tuple of the form (control widget: QComboBox, associated label: QLabel) """ # Create the widget that will be used to select a value widget = Qt.QWidget(parent) # we have a combobox for the trait type, and one of the control types # implementations depending on it layout = Qt.QVBoxLayout() widget.setLayout(layout) widget.type_combo = Qt.QComboBox() hlayout = Qt.QHBoxLayout() #layout.addLayout(hlayout) lwidget = Qt.QWidget() lwidget.setLayout(hlayout) hlayout.addWidget(Qt.QLabel('Compound type:')) hlayout.addWidget(widget.type_combo) widget.header_widget = lwidget widget.user_data = user_data # get compound types types = trait_ids(trait) for t in types: widget.type_combo.addItem(t) widget.type_combo.setCurrentIndex(0) widget.compound_widget = None widget.trait = trait # we need to access it later widget.trait_name = control_name widget.compound_label = None type_id = CompoundControlWidget.type_id_for(trait.handler.handlers, control_value) widget.current_type_id = type_id widget.type_combo.setCurrentIndex(type_id) CompoundControlWidget.create_compound_widget(widget) widget.type_combo.currentIndexChanged.connect( partial(CompoundControlWidget.change_type_index, widget)) # Add a parameter to tell us if the widget is optional widget.optional = trait.optional # Create the label associated with the enum widget control_label = trait.label if control_label is None: control_label = control_name if label_class is None: label_class = Qt.QLabel if control_label is not None: label = (label_class(control_label, parent), lwidget) else: label = lwidget return (widget, label)