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): QtGui.QMainWindow.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint) #Load ui file uifile = 'second_window.ui' cwd = os.getcwd() mainwindowdir = os.path.join(cwd, 'user_interface/data_viewer/anatomist_2') os.chdir(mainwindowdir) awin = loadUi(os.path.join(mainwindowdir, uifile)) os.chdir(cwd) # connect GUI actions callbacks def findChild(x, y): return Qt.QObject.findChild(x, QtCore.QObject, y) self.window = awin self.viewNewWindow = findChild(awin, 'windows') self.newViewLay = Qt.QHBoxLayout(self.viewNewWindow) self.new_awindow = None self.object = None self.window_index = 0 self.popup_window = Qt.QWidget() self.popup_window.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) self.popups = [] self.layout = Qt.QVBoxLayout() self.popup_window.setLayout(self.layout) self.popup_window.resize(730, 780) self.window.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) #find views viewButtons self.viewButtons = [ findChild(awin, 'actionAxial'), findChild(awin, 'actionSagittal'), findChild(awin, 'actionCoronal'), findChild(awin, 'action3D') ] self.viewButtons[0].setChecked(True) self.viewButtons[0].triggered.connect( lambda: self.changeDisplay(0, self.object)) self.viewButtons[1].triggered.connect( lambda: self.changeDisplay(1, self.object)) self.viewButtons[2].triggered.connect( lambda: self.changeDisplay(2, self.object)) self.viewButtons[3].triggered.connect( lambda: self.changeDisplay(3, self.object))
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 filter_documents(self): dialog = Qt.QDialog() layout = Qt.QVBoxLayout() dialog.setLayout(layout) table_data = TableDataBrowser( self.project, self, self.project.session.get_shown_tags(), False, True, link_viewer=False) layout.addWidget(table_data) hlay = Qt.QHBoxLayout() layout.addLayout(hlay) ok = Qt.QPushButton('Display') 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) # Reducing the list of scans to selection all_scans = table_data.scans_to_visualize table_data.scans_to_visualize = self.documents table_data.scans_to_search = self.documents table_data.update_visualized_rows(all_scans) res = dialog.exec_() if res == Qt.QDialog.Accepted: points = table_data.selectedIndexes() result_names = [] for point in points: row = point.row() # We get the FileName of the scan from the first row scan_name = table_data.item(row, 0).text() value = self.project.session.get_value(COLLECTION_CURRENT, scan_name, TAG_FILENAME) value = os.path.abspath(os.path.join(self.project.folder, value)) result_names.append(value) self.display_files(result_names)
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 filter_documents(self): '''Filter documents already loaded in the Databrowser ''' dialog = Qt.QDialog() dialog.setWindowTitle('Filter documents') dialog.resize(1150, 500) layout = Qt.QVBoxLayout() dialog.setLayout(layout) #Some specific filtering #QLineEdit for research self.search_bar = RapidSearch(dialog) self.search_bar.textChanged.connect(self.search_str) #Cancel search button sources_images_dir = Config().getSourceImageDir() button_cross = QToolButton() button_cross.setStyleSheet('background-color:rgb(255, 255, 255);') button_cross.setIcon( QIcon(os.path.join(sources_images_dir, 'gray_cross.png'))) button_cross.clicked.connect(self.reset_search_bar) title = Qt.QLabel() title.setText('Search by FileName: ') layout.addWidget(title) search_bar_layout = QHBoxLayout() search_bar_layout.addWidget(self.search_bar) search_bar_layout.addSpacing(3) search_bar_layout.addWidget(button_cross) #Add layout to dialogBox layout.addLayout(search_bar_layout) layout.addSpacing(8) self.table_data = TableDataBrowser( self.project, self, self.project.session.get_shown_tags(), False, True, link_viewer=False) layout.addWidget(self.table_data) hlay = Qt.QHBoxLayout() layout.addLayout(hlay) ok = Qt.QPushButton('Import') 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) # Reducing the list of scans to selection all_scans = self.table_data.scans_to_visualize self.table_data.scans_to_visualize = self.documents self.table_data.scans_to_search = self.documents self.table_data.update_visualized_rows(all_scans) res = dialog.exec_() if res == Qt.QDialog.Accepted: points = self.table_data.selectedIndexes() result_names = [] for point in points: row = point.row() # We get the FileName of the scan from the first row scan_name = self.table_data.item(row, 0).text() value = self.project.session.get_value(COLLECTION_CURRENT, scan_name, TAG_FILENAME) value = os.path.abspath( os.path.join(self.project.folder, value)) result_names.append(value) self.display_files(result_names)
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)