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 _create_group_widget(self, group): group_widget = QtGui.QGroupBox() last_row = self._grid_layout.rowCount() self._grid_layout.addWidget(group_widget, last_row, 0, 1, 2) lay1 = QtGui.QVBoxLayout() lay1.setContentsMargins(0, 0, 0, 0) lay2 = QtGui.QHBoxLayout() lay1.addLayout(lay2) lay2.setContentsMargins(10, 0, 0, 0) lay2.addWidget(QtGui.QLabel('<html><em>%s</em></html>' % group)) lay2.addStretch(1) icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap(_fromUtf8(":/soma_widgets_icons/nav_down")), QtGui.QIcon.Normal, QtGui.QIcon.Off) group_widget.fold_button = QtGui.QPushButton(icon, '') group_widget.fold_button.setFixedSize(30, 20) lay2.addWidget(group_widget.fold_button) widget = QtGui.QWidget() group_widget.setLayout(lay1) lay1.addWidget(widget) group_widget.hideable_widget = widget layout = QtGui.QGridLayout() widget.setLayout(layout) layout.setAlignment(QtCore.Qt.AlignTop) layout.setSpacing(3) layout.setContentsMargins(5, 5, 5, 5) group_widget.setAlignment(QtCore.Qt.AlignLeft) visible_groups = getattr(self.controller, 'visible_groups', set()) if group in visible_groups: show = True else: show = False group_widget.hideable_widget.setVisible(show) if not show: icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap(_fromUtf8(":/soma_widgets_icons/nav_right")), QtGui.QIcon.Normal, QtGui.QIcon.Off) group_widget.fold_button.setIcon(icon) #group_widget.fold_button.clicked.connect(SomaPartial( #self._toggle_group_visibility, group)) # FIXME: if we use this, self gets deleted somewhere. This is not # normal. group_widget.fold_button.clicked.connect( partial(self.__class__._toggle_group_visibility, weak_proxy(self), group)) return group_widget
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()
def __init__(self, controller, parent=None, name=None, live=False, hide_labels=False, select_controls=None, editable_labels=False): """ 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 live: bool (optional, default False) if True, synchronize the edited values in the widget with the controller values on the fly, otherwise, wait the synchronization instruction to update the controller values. hide_labels: bool (optional, default False) if True, don't show the labels associated with the controls select_controls: str (optional, default None) parameter to select specific conrtoller traits. Authorized options are 'inputs' or 'outputs'. editable_labels: bool (optional, default False) if True, labels (trait keys) may be edited by the user, their modification will trigger a signal. """ # Inheritance super(ControllerWidget, self).__init__(parent) QtCore.QResource.registerResource( os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'widgets_icons.rcc')) # Class parameters self.controller = controller self.live = live self.hide_labels = hide_labels self.select_controls = select_controls # Parameter to store the connection status between the # controller widget and the controller self.connected = False # Parameter to store all the controller widget controls: # the keys correspond to the control name (a control name is # associated to a controller trait with the same name), the # dictionary elements are 4-uplets of the form (trait, control_class, # control_instance, control_label). self._controls = {} self._keys_connections = {} self.editable_labels = editable_labels # If possilbe, set the widget name if name: self.setObjectName(name) # Create the layout of the controller widget # We will add all the controls to this layout self._grid_layout = QtGui.QGridLayout() self._grid_layout.setAlignment(QtCore.Qt.AlignTop) self._grid_layout.setSpacing(3) self._grid_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self._grid_layout) self._groups = OrderedDict() # Create all the layout controls associated with the controller values # we want to tune (ie the user traits) self._create_controls() self.connect_keys() # Start the event loop that check for wrong edited fields (usefull # when we work off line, otherwise the traits make the job but it is # still user friendly). self._check() # Set the synchrinization between this object and the input controller: # 1) synchronize the edited values in the widget with the controller # values on the fly if self.live: self.connect() # 2) initialize the controller widget with the controller values and # wait synchronization instructions to update the controller values. else: self.update_controller_widget()