def setupUi(self, Form): Form.setObjectName(_fromUtf8("QRangeSlider")) Form.resize(300, 30) Form.setStyleSheet(_fromUtf8(DEFAULT_CSS)) self.gridLayout = QtGui.QGridLayout(Form) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setSpacing(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self._splitter = QtGui.QSplitter(Form) self._splitter.setMinimumSize(QtCore.QSize(0, 0)) self._splitter.setMaximumSize(QtCore.QSize(16777215, 16777215)) self._splitter.setOrientation(QtCore.Qt.Horizontal) self._splitter.setObjectName(_fromUtf8("splitter")) self._head = QtGui.QGroupBox(self._splitter) self._head.setTitle(_fromUtf8("")) self._head.setObjectName(_fromUtf8("Head")) self._handle = QtGui.QGroupBox(self._splitter) self._handle.setTitle(_fromUtf8("")) self._handle.setObjectName(_fromUtf8("Span")) self._tail = QtGui.QGroupBox(self._splitter) self._tail.setTitle(_fromUtf8("")) self._tail.setObjectName(_fromUtf8("Tail")) self.gridLayout.addWidget(self._splitter, 0, 0, 1, 1) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setTextColor(self, color): """set the text paint color""" if type(color) == tuple and len(color) == 3: color = QtGui.QColor(color[0], color[1], color[2]) elif type(color) == int: color = QtGui.QColor(color, color, color) setattr(self, '__textColor', color)
def onHelpClicked(self): """ Event to display the documentation of the active pipeline. """ # Create a dialog box to display the html documentation win = QtGui.QDialog() win.setWindowTitle("Pipeline Help") # Build the pipeline documentation location # Possible since common tools generate the sphinx documentation if self.pipeline: # Generate the url to the active pipeline documentation path_to_active_pipeline_doc = os.path.join( self.path_to_pipeline_doc[self.pipeline.id], "generated", self.pipeline.id.split(".")[1], "pipeline", self.pipeline.id + ".html") # Create and fill a QWebView help = QtWebKit.QWebView() help.load(QtCore.QUrl(path_to_active_pipeline_doc)) help.show() # Create and set a layout with the web view layout = QtGui.QHBoxLayout() layout.addWidget(help) win.setLayout(layout) # Display the window win.exec_() # No Pipeline loaded, cant't show the documentation message # Display a message box else: QtGui.QMessageBox.information(self.ui, "Information", "First load a pipeline!")
def is_valid(control_instance, *args, **kwargs): """ Method to check if the new control value is correct. If the new entered value is not correct, the backroung control color will be red. Parameters ---------- control_instance: QWidget (mandatory) the control widget we want to validate Returns ------- out: bool True if the control value is a file, False otherwise """ # Get the current control palette control_palette = control_instance.path.palette() # Get the control current value control_value = control_instance.path.value() color = QtCore.Qt.white red = QtGui.QColor(255, 220, 220) yellow = QtGui.QColor(255, 255, 200) # If the control value contains a file, the control is valid and the # backgound color of the control is white is_valid = False if control_value is traits.Undefined: # Undefined is an exception: allow to reset it (File instances, # even mandatory, are initialized with Undefined value) is_valid = True if not control_instance.optional: color = red else: if os.path.isdir(control_value) \ or (control_instance.output and control_value != "") \ or (control_instance.trait.handler.exists is False and control_value != ""): is_valid = True # If the control value is optional, the control is valid and the # backgound color of the control is yellow elif control_instance.optional is True and control_value == "": color = yellow is_valid = True # If the control value is empty, the control is not valid and the # backgound color of the control is red else: color = red # Set the new palette to the control instance control_palette.setColor(control_instance.path.backgroundRole(), color) control_instance.path.setPalette(control_palette) return is_valid
def expand_or_collapse(control_instance, resize_button): """ Callback to expand or collapse a 'DictControlWidget'. Parameters ---------- control_instance: QFrame (mandatory) the dict widget item resize_button: QToolButton the signal sender """ # Change the icon depending on the button status icon = QtGui.QIcon() # Hide the control if control_instance.isVisible(): control_instance.hide() icon.addPixmap(QtGui.QPixmap(_fromUtf8( ":/soma_widgets_icons/nav_right")), QtGui.QIcon.Normal, QtGui.QIcon.Off) # Show the control else: control_instance.show() icon.addPixmap(QtGui.QPixmap(_fromUtf8( ":/soma_widgets_icons/nav_down")), QtGui.QIcon.Normal, QtGui.QIcon.Off) # Set the new button icon resize_button.setIcon(icon)
def set_expanded(control_instance, resize_button, state): """ Expand or collapse a 'ControllerControlWidget'. Parameters ---------- control_instance: QFrame (mandatory) the list widget item resize_button: QToolButton the signal sender state: bool expanded (True) or collapsed (False) """ # Change the icon depending on the button status icon = QtGui.QIcon() # Hide the control if not state: control_instance.hide() icon.addPixmap( QtGui.QPixmap(_fromUtf8(":/soma_widgets_icons/nav_right")), QtGui.QIcon.Normal, QtGui.QIcon.Off) # Show the control else: control_instance.show() icon.addPixmap( QtGui.QPixmap(_fromUtf8(":/soma_widgets_icons/nav_down")), QtGui.QIcon.Normal, QtGui.QIcon.Off) # Set the new button icon resize_button.setIcon(icon)
def __init__(self, viewer_node_name, pipeline, study_config): """ Method to initialize a ViewerWidget class. Parameters ---------- viewer_node_name: str the name of the node containing the viewer process pipeline: str the full pipeline in order to get the viewer input trait values since the viewer node is unactivated """ # Inheritance super(ViewerWidget, self).__init__() # Default parameters self.viewer_node_name = viewer_node_name self.pipeline = pipeline self.study_config = study_config # Build control button = QtGui.QToolButton(self) button.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) button.setMinimumHeight(50) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/icones/view_result")), QtGui.QIcon.Normal, QtGui.QIcon.Off) button.setIcon(icon) button.clicked.connect(self.onCreateViewerClicked)
def is_valid(control_instance, *args, **kwargs): """ Method to check if the new control value is correct. If the new entered value is not correct, the backroung control color will be red. Parameters ---------- control_instance: QLineEdit (mandatory) the control widget we want to validate Returns ------- out: bool True if the control value is valid, False otherwise """ # Get the current control palette control_palette = control_instance.palette() # Get the control current value: format the float string # Valid float strings are: +1, -1, 1, 1.1 control_text = control_instance.text() if type(control_text) not in (str, six.text_type): # old QString with PyQt API v1 control_text = six.text_type(control_text) control_value = control_text.replace(".", "", 1) control_value = re.sub("^([-+])", "", control_value, count=1) red = QtGui.QColor(255, 220, 220) yellow = QtGui.QColor(255, 255, 200) # If the control value contains only digits, the control is valid and # the backgound color of the control is white is_valid = False if control_value.isdigit(): control_palette.setColor(control_instance.backgroundRole(), QtCore.Qt.white) is_valid = True # If the control value is optional, the control is valid and the # backgound color of the control is yellow elif control_instance.optional is True and control_value == "": control_palette.setColor(control_instance.backgroundRole(), yellow) is_valid = True # If the control value is empty, the control is not valid and the # backgound color of the control is red else: control_palette.setColor(control_instance.backgroundRole(), red) # Set the new palette to the control instance control_instance.setPalette(control_palette) return is_valid
def _set_group_visibility(self, group, checked): group_widget = self._groups[group] group_widget.hideable_widget.setVisible(checked) icon = QtGui.QIcon() if checked: icon.addPixmap( QtGui.QPixmap(_fromUtf8(":/soma_widgets_icons/nav_down")), QtGui.QIcon.Normal, QtGui.QIcon.Off) else: icon.addPixmap( QtGui.QPixmap(_fromUtf8(":/soma_widgets_icons/nav_right")), QtGui.QIcon.Normal, QtGui.QIcon.Off) group_widget.fold_button.setIcon(icon)
def is_valid(control_instance, *args, **kwargs): """ Method to check if the new control value is correct. If the new entered value is not correct, the backroung control color will be red. Parameters ---------- control_instance: QLineEdit (mandatory) the control widget we want to validate Returns ------- out: bool True if the control value is valid, False otherwise """ # Get the current control palette control_palette = control_instance.palette() # Get the control current value control_value = control_instance.value() color = QtCore.Qt.white red = QtGui.QColor(255, 220, 220) yellow = QtGui.QColor(255, 255, 200) # If the control value is not empty, the control is valid and the # backgound color of the control is white is_valid = False if control_value in ('', None, traits.Undefined): if control_instance.optional: # If the control value is optional, the control is valid and # the backgound color of the control is yellow color = yellow is_valid = True else: color = red if control_value != '': # allow to reset value is_valid = True else: is_valid = True # Set the new palette to the control instance control_palette.setColor(control_instance.backgroundRole(), color) control_instance.setPalette(control_palette) return is_valid
def inlineGUI(self, values, pview, parent, externalRunButton=False): from soma.qt_gui.qt_backend import QtGui from brainvisa.processing.qtgui import neuroProcessesGUI vb = QtGui.QWidget() lay = QtGui.QVBoxLayout(vb) lay.addWidget( neuroProcessesGUI.ProcessView.defaultInlineGUI(pview, vb, externalRunButton, None)) lay.addWidget( QtGui.QLabel( _t_('The SPM paths have not been setup in the configuration.\nCurrently, processes using SPM might not work,\nand the SPM database (normalization templates...) cannot be used.\nThis process can try to detect it and set it in the configuration.\nYou should re-open any process depending on SPM afterwards.' ), vb)) return vb
def update_links_view(self): self.ui.links_table.clearContents() self.ui.links_table.setRowCount(0) # IMPORTANT otherwise perf drops table_header = self.ui.links_table.horizontalHeader() table_header.setResizeMode(QtGui.QHeaderView.Interactive) l = 0 self.record_stream.flush() f = open(self.record_file) lines = f.readlines() self.ui.links_table.setRowCount(len(lines)) linkre = re.compile( '^value link: from: ([^ ,]+) *to: ([^ ]+) *, value: ([^ ]+).*$') links_orgs = {} for line in lines: match = linkre.match(line) if match: link_source = match.group(1) link_dest = match.group(2) plug_value = match.group(3) self.ui.links_table.setItem(l, 0, QtGui.QTableWidgetItem('%04d' % l)) self.ui.links_table.setItem( l, self.PLUG, QtGui.QTableWidgetItem(link_source)) self.ui.links_table.setItem(l, self.PROPAGATE, QtGui.QTableWidgetItem(link_dest)) self.ui.links_table.setItem(l, self.VALUE, QtGui.QTableWidgetItem(plug_value)) links_orgs.setdefault(link_dest, []).append(l) if link_source in links_orgs: org = links_orgs[link_source][0] self.ui.links_table.setItem( l, self.CAUSE, QtGui.QTableWidgetItem(self.ui.links_table.item( org, 2))) l += 1 self.links_orgs = links_orgs table_header.setResizeMode(QtGui.QHeaderView.ResizeToContents) #table_header.setResizeMode(1, QtGui.QHeaderView.ResizeToContents) #table_header.setResizeMode(2, QtGui.QHeaderView.ResizeToContents) #table_header.setResizeMode(3, QtGui.QHeaderView.ResizeToContents) #table_header.setResizeMode(4, QtGui.QHeaderView.ResizeToContents) #table_header.setResizeMode(QtGui.QHeaderView.Interactive) QtGui.qApp.processEvents() #table_header.resizeSection(0, table_header.sectionSizeHint(0)) #table_header.resizeSection(1, table_header.sectionSizeHint(1)) #table_header.resizeSection(2, table_header.sectionSizeHint(2)) #table_header.resizeSection(3, table_header.sectionSizeHint(3)) #table_header.resizeSection(4, table_header.sectionSizeHint(4)) table_header.setResizeMode(QtGui.QHeaderView.Interactive)
def __init__(self, parent, controller_widget, control_name): super(ListValuesEditor, self).__init__(parent) self.controller_widget = controller_widget self.control_name = control_name self.format = 'JSON' self.separator = ',' self.modified = False layout = QtGui.QVBoxLayout() self.setLayout(layout) textedit = QtGui.QTextEdit() layout.addWidget(textedit) hlayout2 = QtGui.QHBoxLayout() layout.addLayout(hlayout2) hlayout2.addWidget(QtGui.QLabel('Format:')) format_c = QtGui.QComboBox() hlayout2.addWidget(format_c) hlayout2.addWidget(QtGui.QLabel('Separator:')) sep_c = QtGui.QComboBox() hlayout2.addWidget(sep_c) format_c.addItem('JSON') format_c.addItem('CSV') sep_c.addItem(',') sep_c.addItem(';') sep_c.addItem(' ') hlayout2.addStretch(1) ok = QtGui.QPushButton('OK') cancel = QtGui.QPushButton('Cancel') hlayout2.addWidget(ok) hlayout2.addWidget(cancel) ok.pressed.connect(self.accept) cancel.pressed.connect(self.reject) parent_controller = controller_widget.controller value = getattr(parent_controller, control_name) text = json.dumps(value) textedit.setText(text) self.textedit = textedit self.format_c = format_c self.separator_c = sep_c self.internal_change = False textedit.textChanged.connect(self.set_modified) format_c.currentIndexChanged.connect(self.format_changed) sep_c.currentIndexChanged.connect(self.separator_changed)
def __init__(self, text=None, parent=None): super(DeletableLineEdit, self).__init__(parent) layout = QtGui.QHBoxLayout() self.setLayout(layout) delete_button = QtGui.QToolButton() layout.addWidget(delete_button) # Set the tool icons icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/soma_widgets_icons/delete")), QtGui.QIcon.Normal, QtGui.QIcon.Off) delete_button.setIcon(icon) self.line_edit = TimeredQLineEdit(text) layout.addWidget(self.line_edit) self.line_edit.userModification.connect(self.userModification) delete_button.pressed.connect(self.buttonPressed)
def __init__(self, pipeline): """ Initialize the WorkflowViewer class """ # Inheritance super(PipelineUserView, self).__init__() # Class attributets self.pipeline = pipeline # Initialize the widget layout = QtGui.QVBoxLayout(self) self.label = QtGui.QLabel() layout.addWidget(self.label) #self.setLayout(layout) self.update()
def run_pipeline_io(self, filename): pipeline = MyPipeline() from capsul.pipeline import pipeline_tools pipeline_tools.save_pipeline(pipeline, filename) pipeline2 = get_process_instance(filename) pipeline2.workflow_ordered_nodes() if self.debug: from soma.qt_gui.qt_backend import QtGui from capsul.qt_gui.widgets import PipelineDeveloperView import sys app = QtGui.QApplication.instance() if not app: app = QtGui.QApplication(sys.argv) view1 = PipelineDeveloperView(pipeline, allow_open_controller=True, enable_edition=True, show_sub_pipelines=True) view2 = PipelineDeveloperView(pipeline2, allow_open_controller=True, enable_edition=True, show_sub_pipelines=True) view1.show() view2.show() app.exec_() self.assertTrue( pipeline2.workflow_repr in ("constant->node1->node2", "node1->constant->node2"), '%s not in ("constant->node1->node2", "node1->constant->node2")' % pipeline2.workflow_repr) d1 = pipeline_tools.dump_pipeline_state_as_dict(pipeline) d2 = pipeline_tools.dump_pipeline_state_as_dict(pipeline2) self.assertEqual(d1, d2)
def paintEvent(self, event): """overrides paint event to handle text""" qp = QtGui.QPainter() qp.begin(self) if self.main.drawValues(): self.drawText(event, qp) qp.end()
def __init__(self, parent=None): """ Create a new QRangeSlider instance. :param parent: QWidget parent :return: New QRangeSlider instance. """ QtGui.QWidget.__init__(self, parent) self.setupUi(self) self.setMouseTracking(False) self._splitter.splitterMoved.connect(self._handleMoveSplitter) # head layout self._head_layout = QtGui.QHBoxLayout() self._head_layout.setSpacing(0) self._head_layout.setContentsMargins(0, 0, 0, 0) self._head.setLayout(self._head_layout) self.head = Head(self._head, main=self) self._head_layout.addWidget(self.head) # handle layout self._handle_layout = QtGui.QHBoxLayout() self._handle_layout.setSpacing(0) self._handle_layout.setContentsMargins(0, 0, 0, 0) self._handle.setLayout(self._handle_layout) self.handle = Handle(self._handle, main=self) self.handle.setTextColor((150, 255, 150)) self._handle_layout.addWidget(self.handle) # tail layout self._tail_layout = QtGui.QHBoxLayout() self._tail_layout.setSpacing(0) self._tail_layout.setContentsMargins(0, 0, 0, 0) self._tail.setLayout(self._tail_layout) self.tail = Tail(self._tail, main=self) self._tail_layout.addWidget(self.tail) # defaults self.setMin(0) self.setMax(99) self.setStart(0) self.setEnd(99) self.setDrawValues(True) self._movingHandle = False
def update(self): image = tempfile.NamedTemporaryFile(suffix=".png") dot = tempfile.NamedTemporaryFile(suffix=".png") self.write(dot) dot.flush() check_call(["dot", "-Tpng", "-o", image.name, dot.name]) self.pixmap = QtGui.QPixmap(image.name) # .scaledToHeight(600) self.label.setPixmap(self.pixmap)
def create_widget(parent, control_name, control_value, trait, label_class=None): """ Method to 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 = QtGui.QComboBox(parent) # Save the possible choices widget._choices = trait.handler.values # Add a parameter to tell us if the widget is optional widget.optional = trait.optional # Set the enum list items to the widget for item in widget._choices: widget.addItem(unicode(item)) # Select the default value # If the default value is not in the enum list, pick the first item # of the enum list if control_value not in widget._choices: widget.setCurrentIndex(0) else: widget.setCurrentIndex(widget._choices.index(control_value)) # 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 = QtGui.QLabel if control_label is not None: label = label_class(control_label, parent) else: label = None return (widget, label)
def select_files(controller_widget, control_name, control_instance): control_instance = get_ref(control_instance) parent_controller = controller_widget.controller elem_trait = parent_controller.trait(control_name).inner_traits[0] fnames = None current_dir = os.path.join(os.getcwd(), os.pardir) if isinstance(elem_trait.trait_type, traits.Directory): # Create a dialog to select a directory fdialog = QtGui.QFileDialog( control_instance, "Open directories", current_dir) fdialog.setOptions(QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog) fdialog.setFileMode(QtGui.QFileDialog.Directory) fdialog.setModal(True) if fdialog.exec_(): fnames = fdialog.selectedFiles() else: if elem_trait.output: fdialog = QtGui.QFileDialog( control_instance, "Output files", current_dir) fdialog.setOptions(QtGui.QFileDialog.DontUseNativeDialog) fdialog.setFileMode(QtGui.QFileDialog.AnyFile) fdialog.setModal(True) if fdialog.exec_(): fnames = fdialog.selectedFiles() else: fdialog = QtGui.QFileDialog( control_instance, "Open files", current_dir) fdialog.setOptions(QtGui.QFileDialog.DontUseNativeDialog) fdialog.setFileMode(QtGui.QFileDialog.ExistingFiles) fdialog.setModal(True) if fdialog.exec_(): fnames = fdialog.selectedFiles() # Set the selected files to the path sub control if fnames is not None: old_value = getattr(parent_controller, control_name) new_value = old_value + fnames setattr(parent_controller, control_name, new_value)
def main(noapp=0): app = None if noapp == 0: print "NO APP" app = QtGui.QApplication(sys.argv) axon.initializeProcesses() ll = LocateLeds(app=app) ll.show() if noapp == 0: sys.exit(app.exec_())
def create_viewer_tree(self): """ Method to create a tree with two columns (pipeline name - viewers) that will summarize all the available quality control nodes """ # Create the tree widget self.viewer_tree = QtGui.QTreeWidget(parent=self) # Initialize the tree widget self.viewer_tree.setColumnCount(2) self.viewer_tree.headerItem().setText(0, "Pipeline Name") self.viewer_tree.headerItem().setText(1, "Viewers")
def _completion_progress_changed(self, obj, name, old, new): completion_engine = getattr(self.attributed_process, 'completion_engine', None) if completion_engine is not None: if not hasattr(self, 'progressdialog'): self.progressdialog = QtGui.QWidget() self.layout().insertWidget(1, self.progressdialog) layout = QtGui.QHBoxLayout() self.progressdialog.setLayout(layout) layout.addWidget(QtGui.QLabel('Completion progress:')) self.progressbar = QtGui.QProgressBar() layout.addWidget(self.progressbar) self.progressbar.setRange(0, 100) value = int(round(100 * completion_engine.completion_progress / completion_engine.completion_progress_total)) self.progressbar.setValue(value) if value != 100: self.progressdialog.show() QtGui.qApp.processEvents() else: self.progressdialog.hide()
def __init__(self, app=None): QtGui.QDialog.__init__(self) self.ui = uic.loadUi("locateleds.ui", self) self.pb = plasticbrain.PlasticBrain() self.ui.startLocaButton.clicked.connect(self.start) self.ui.loadMeshButton.clicked.connect(self.loadMesh) self.ui.deviceCombo.currentIndexChanged.connect( self.updatedDeviceCombo) self.ui.saveButton.clicked.connect(self.save) self.ui.nextLedButton.clicked.connect(self.nextLed) self.ui.previousLedButton.clicked.connect(self.previousLed) self.ui.ReceiveLSLButton.clicked.connect(self.ReceiveAndDisplayEEG) self.ui.StopReceiveData.clicked.connect(self.StopReceiveData) self.a = anatomist.Anatomist('-b') #Batch mode (hide Anatomist window) self.a.onCursorNotifier.add(self.clickHandler) pix = QtGui.QPixmap('control.xpm') self.app = app anatomistControl.cpp.IconDictionary.instance().addIcon( 'MyControl', pix) ad = anatomistControl.cpp.ActionDictionary.instance() ad.addAction('MyAction', lambda: MyAction()) cd = anatomistControl.cpp.ControlDictionary.instance() cd.addControl('MyControl', lambda: MyControl(), 25) cm = anatomistControl.cpp.ControlManager.instance() cm.addControl('QAGLWidget3D', '', 'MyControl') self.axWindow = self.a.createWindow('Axial') layoutAx = QtGui.QHBoxLayout(self.frame) self.axWindow.setParent(self.frame) layoutAx.addWidget(self.axWindow.getInternalRep()) self.currentElec = 0 self.coords = [ [0, 0, 0], ] self.mesh = None self.aimsMesh = None self.texture = None self.currentObj = None self.TextObj = None
def add_tree_nodes(parent_item, menu, match, parent_module=""): """ Add the menu to tree control if match in current module name or child modules. The match is insensitive to the cast. Parameters ---------- parent_item: QTreeWidgetItem (mandatory) a tree control item where we want to insert the menu menu: hierachic dict (mandatory) each key is a sub module of the module. Leafs contain a list with the url to the documentation. match: str (mandatory) the string used to filter the menu items parent_module: str (optional) the parent module string description ('module.sub_module') """ # Go through the current module sub modules for module_name, child_modules in six.iteritems(menu): # Filtering: check if we need to add this module in the tree if (match == "" or match in module_name.lower() or search_in_menu(child_modules, match)): # Add the module name to the tree control if isinstance(child_modules, dict): tree_item = QtGui.QTreeWidgetItem( parent_item, [module_name, "None", "None"]) if parent_module: current_module = parent_module + "." + module_name else: current_module = module_name add_tree_nodes(tree_item, child_modules, match, current_module) else: tree_item = QtGui.QTreeWidgetItem( parent_item, [module_name, parent_module, child_modules[0]]) tree_item.setFont(0, font)
def add_save_button(self, win): if neuroConfig.anatomistImplementation == 'socket': return None # cannot add buttons via socket API from soma.wip.application.api import findIconFile from soma.qt_gui.qt_backend import QtGui, QtCore toolbar = win.findChild(QtGui.QToolBar, 'mutations') if toolbar is None: toolbar = win.findChild(QtGui.QToolBar) if toolbar is None: toolbar = win.addToolBar('BV toolbar') if win.toolBarsVisible(): toolbar.show() if toolbar is not None: toolbar.addSeparator() icon = QtGui.QIcon(findIconFile('save.png')) ac = QtGui.QAction(icon, win.tr('Save ROI', 'QAWindow'), win.getInternalRep()) toolbar.addAction(ac) ac.triggered.connect(self.save_roi) self.win_deleted = False self.local_event_loop = None win.getInternalRep().destroyed.connect(self.close_and_save) return ac
def create_board_tree(self): """ Method to create a tree with five columns (processings - status - execution time - memory - logs) that will summarize all the available quality control nodes """ # Create the tree widget self.board_tree = QtGui.QTreeWidget(parent=self) # Initialize the tree widget self.board_tree.setColumnCount(5) self.board_tree.headerItem().setText(0, "Processings") self.board_tree.headerItem().setText(1, "Status") self.board_tree.headerItem().setText(2, "Execution Time") self.board_tree.headerItem().setText(3, "Memory") self.board_tree.headerItem().setText(4, "Logs")
def create_widget(parent, control_name, control_value, trait, label_class=None, user_data=None): """ Method to create the bool 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 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: QLineEdit, associated label: QLabel) """ # Create the widget that will be used to select an option widget = QtGui.QCheckBox(parent) # Add a widget parameter to tell us if the widget is already connected widget.connected = False # Create the label associated with the bool widget control_label = trait.label if control_label is None: control_label = control_name if label_class is None: label_class = QtGui.QLabel if control_label is not None: label = label_class(control_label, parent) else: label = None return (widget, label)
def __init__(self, controller, parent=None, name=None): """ Method to initilaize the ControllerWidget class. Parameters ---------- controller: derived Controller instance (mandatory) a class derived from the Controller class we want to parametrize with a widget. parent: QtGui.QWidget (optional, default None) the controller widget parent widget. name: (optional, default None) the name of this controller widget """ # Inheritance super(BoardWidget, self).__init__(parent) # Class parameters self.controller = controller # If possible, set the widget name if name: self.setObjectName(name) # Create the layout of the board widget # Three item layout: output_controller_widget - board_tree - viewer_tree self._grid_layout = QtGui.QGridLayout() self._grid_layout.setAlignment(QtCore.Qt.AlignTop) self._grid_layout.setSpacing(3) self._grid_layout.setContentsMargins(5, 5, 5, 5) self.setLayout(self._grid_layout) # Create all the controls self.create_output_widget() self.create_viewer_tree() self.create_board_tree() # Fill the grid layout self._grid_layout.addWidget(self.board_tree, 0, 0, 1, 2) self._grid_layout.addWidget(self.output_controller_widget, 1, 0, 1, 1) self._grid_layout.addWidget(self.viewer_tree, 1, 1, 1, 1) # Create the board self._fill_trees()