Ejemplo n.º 1
0
 def addChild(
         self, child
 ):  ## make sure added childs are actually inserted before add btn
     if self.addItem is not None:
         ParameterItem.insertChild(self, self.childCount() - 1, child)
     else:
         ParameterItem.addChild(self, child)
Ejemplo n.º 2
0
    def limitsChanged(self, param, limits):
        """Called when the parameter's limits have changed"""
        ParameterItem.limitsChanged(self, param, limits)

        t = self.param.opts['type']
        if t == 'int' or t == 'float':
            self.widget.setOpts(bounds=limits)
        else:
            return  ## don't know what to do with any other types..
Ejemplo n.º 3
0
 def limitsChanged(self, param, limits):
     """Called when the parameter's limits have changed"""
     ParameterItem.limitsChanged(self, param, limits)
     
     t = self.param.opts['type']
     if t == 'int' or t == 'float':
         self.widget.setOpts(bounds=limits)
     else:
         return  ## don't know what to do with any other types..
Ejemplo n.º 4
0
 def selected(self, sel):
     """Called when this item has been selected (sel=True) OR deselected (sel=False)"""
     ParameterItem.selected(self, sel)
     
     if self.widget is None:
         return
     if sel and self.param.writable():
         self.showEditor()
     elif self.hideWidget:
         self.hideEditor()
Ejemplo n.º 5
0
    def selected(self, sel):
        """Called when this item has been selected (sel=True) OR deselected (sel=False)"""
        ParameterItem.selected(self, sel)

        if self.widget is None:
            return
        if sel and self.param.writable():
            self.showEditor()
        elif self.hideWidget:
            self.hideEditor()
Ejemplo n.º 6
0
    def treeWidgetChanged(self):
        """Called when this item is added or removed from a tree."""
        ParameterItem.treeWidgetChanged(self)

        ## add all widgets for this item into the tree
        if self.widget is not None:
            tree = self.treeWidget()
            if tree is None:
                return
            tree.setItemWidget(self, 1, self.layoutWidget)
            self.displayLabel.hide()
            self.selected(False)
Ejemplo n.º 7
0
 def treeWidgetChanged(self):
     """Called when this item is added or removed from a tree."""
     ParameterItem.treeWidgetChanged(self)
     
     ## add all widgets for this item into the tree
     if self.widget is not None:
         tree = self.treeWidget()
         if tree is None:
             return
         tree.setItemWidget(self, 1, self.layoutWidget)
         self.displayLabel.hide()
         self.selected(False)            
Ejemplo n.º 8
0
 def valueChanged(self, param, val, force=False):
     ## called when the parameter's value has changed
     ParameterItem.valueChanged(self, param, val)
     
     self.widget.sigChanged.disconnect(self.widgetValueChanged)
     try:
         if force or val != self.widget.value():
             self.widget.setValue(val)
         self.updateDisplayLabel(val)  ## always make sure label is updated, even if values match!
     finally:
         self.widget.sigChanged.connect(self.widgetValueChanged)
     self.updateDefaultBtn()
Ejemplo n.º 9
0
    def valueChanged(self, param, val, force=False):
        ## called when the parameter's value has changed
        ParameterItem.valueChanged(self, param, val)

        self.widget.sigChanged.disconnect(self.widgetValueChanged)
        try:
            if force or val != self.widget.value():
                self.widget.setValue(val)
            self.updateDisplayLabel(
                val
            )  ## always make sure label is updated, even if values match!
        finally:
            self.widget.sigChanged.connect(self.widgetValueChanged)
        self.updateDefaultBtn()
Ejemplo n.º 10
0
    def optsChanged(self, param, opts):
        """Called when any options are changed that are not
        name, value, default, or limits"""
        #print "opts changed:", opts
        ParameterItem.optsChanged(self, param, opts)

        if 'readonly' in opts:
            self.updateDefaultBtn()

        ## If widget is a SpinBox, pass options straight through
        if isinstance(self.widget, SpinBox):
            if 'units' in opts and 'suffix' not in opts:
                opts['suffix'] = opts['units']
            self.widget.setOpts(**opts)
            self.updateDisplayLabel()
Ejemplo n.º 11
0
 def optsChanged(self, param, opts):
     """Called when any options are changed that are not
     name, value, default, or limits"""
     #print "opts changed:", opts
     ParameterItem.optsChanged(self, param, opts)
     
     if 'readonly' in opts:
         self.updateDefaultBtn()
     
     ## If widget is a SpinBox, pass options straight through
     if isinstance(self.widget, SpinBox):
         if 'units' in opts and 'suffix' not in opts:
             opts['suffix'] = opts['units']
         self.widget.setOpts(**opts)
         self.updateDisplayLabel()
Ejemplo n.º 12
0
    def __init__(self, param, depth):
        ParameterItem.__init__(self, param, depth)
        if depth == 0:
            for c in [0, 1]:
                self.setBackground(c, QtGui.QBrush(QtGui.QColor(100, 100,
                                                                100)))
                self.setForeground(c, QtGui.QBrush(QtGui.QColor(220, 220,
                                                                255)))
                font = self.font(c)
                font.setBold(True)
                font.setPointSize(font.pointSize() + 1)
                self.setFont(c, font)
                self.setSizeHint(0, QtCore.QSize(0, 25))
        else:
            for c in [0, 1]:
                self.setBackground(c, QtGui.QBrush(QtGui.QColor(220, 220,
                                                                220)))
                font = self.font(c)
                font.setBold(True)
                #font.setPointSize(font.pointSize()+1)
                self.setFont(c, font)
                self.setSizeHint(0, QtCore.QSize(0, 20))

        self.addItem = None
        if 'addText' in param.opts:
            addText = param.opts['addText']
            if 'addList' in param.opts:
                self.addWidget = QtGui.QComboBox()
                self.addWidget.addItem(addText)
                for t in param.opts['addList']:
                    self.addWidget.addItem(t)
                self.addWidget.currentIndexChanged.connect(self.addChanged)
            else:
                self.addWidget = QtGui.QPushButton(addText)
                self.addWidget.clicked.connect(self.addClicked)
            w = QtGui.QWidget()
            l = QtGui.QHBoxLayout()
            l.setContentsMargins(0, 0, 0, 0)
            w.setLayout(l)
            l.addWidget(self.addWidget)
            l.addItem(
                QtGui.QSpacerItem(200, 10, QtGui.QSizePolicy.Expanding,
                                  QtGui.QSizePolicy.Minimum))
            self.addWidgetBox = w
            self.addItem = QtGui.QTreeWidgetItem([])
            self.addItem.setFlags(QtCore.Qt.ItemIsEnabled)
            ParameterItem.addChild(self, self.addItem)
Ejemplo n.º 13
0
 def makeTreeItem(self, depth):
     """Return a TreeWidgetItem suitable for displaying/controlling the content of this parameter.
     Most subclasses will want to override this function.
     """
     if hasattr(self, 'itemClass'):
         #print "Param:", self, "Make item from itemClass:", self.itemClass
         return self.itemClass(self, depth)
     else:
         return ParameterItem(self, depth=depth)
Ejemplo n.º 14
0
 def __init__(self, param, depth):
     ParameterItem.__init__(self, param, depth)
     if depth == 0:
         for c in [0,1]:
             self.setBackground(c, QtGui.QBrush(QtGui.QColor(100,100,100)))
             self.setForeground(c, QtGui.QBrush(QtGui.QColor(220,220,255)))
             font = self.font(c)
             font.setBold(True)
             font.setPointSize(font.pointSize()+1)
             self.setFont(c, font)
             self.setSizeHint(0, QtCore.QSize(0, 25))
     else:
         for c in [0,1]:
             self.setBackground(c, QtGui.QBrush(QtGui.QColor(220,220,220)))
             font = self.font(c)
             font.setBold(True)
             #font.setPointSize(font.pointSize()+1)
             self.setFont(c, font)
             self.setSizeHint(0, QtCore.QSize(0, 20))
             
     self.addItem = None
     if 'addText' in param.opts:
         addText = param.opts['addText']
         if 'addList' in param.opts:
             self.addWidget = QtGui.QComboBox()
             self.addWidget.addItem(addText)
             for t in param.opts['addList']:
                 self.addWidget.addItem(t)
             self.addWidget.currentIndexChanged.connect(self.addChanged)
         else:
             self.addWidget = QtGui.QPushButton(addText)
             self.addWidget.clicked.connect(self.addClicked)
         w = QtGui.QWidget()
         l = QtGui.QHBoxLayout()
         l.setContentsMargins(0,0,0,0)
         w.setLayout(l)
         l.addWidget(self.addWidget)
         l.addItem(QtGui.QSpacerItem(200, 10, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum))
         self.addWidgetBox = w
         self.addItem = QtGui.QTreeWidgetItem([])
         self.addItem.setFlags(QtCore.Qt.ItemIsEnabled)
         ParameterItem.addChild(self, self.addItem)
Ejemplo n.º 15
0
    def __init__(self, param, depth):
        ParameterItem.__init__(self, param, depth)

        self.hideWidget = True  ## hide edit widget, replace with label when not selected
        ## set this to False to keep the editor widget always visible

        ## build widget into column 1 with a display label and default button.
        w = self.makeWidget()
        self.widget = w
        self.eventProxy = EventProxy(w, self.widgetEventFilter)

        opts = self.param.opts
        if 'tip' in opts:
            w.setToolTip(opts['tip'])

        self.defaultBtn = QtGui.QPushButton()
        self.defaultBtn.setFixedWidth(20)
        self.defaultBtn.setFixedHeight(20)
        modDir = os.path.dirname(__file__)
        self.defaultBtn.setIcon(
            QtGui.QIcon(os.path.join(modDir, 'default.png')))
        self.defaultBtn.clicked.connect(self.defaultClicked)

        self.displayLabel = QtGui.QLabel()

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(2)
        layout.addWidget(w)
        layout.addWidget(self.displayLabel)
        layout.addWidget(self.defaultBtn)
        self.layoutWidget = QtGui.QWidget()
        self.layoutWidget.setLayout(layout)

        if w.sigChanged is not None:
            w.sigChanged.connect(self.widgetValueChanged)

        if hasattr(w, 'sigChanging'):
            w.sigChanging.connect(self.widgetValueChanging)

        ## update value shown in widget.
        self.valueChanged(self, opts['value'], force=True)
Ejemplo n.º 16
0
 def __init__(self, param, depth):
     ParameterItem.__init__(self, param, depth)
     
     self.hideWidget = True  ## hide edit widget, replace with label when not selected
                             ## set this to False to keep the editor widget always visible
     
     
     ## build widget into column 1 with a display label and default button.
     w = self.makeWidget()  
     self.widget = w
     self.eventProxy = EventProxy(w, self.widgetEventFilter)
     
     opts = self.param.opts
     if 'tip' in opts:
         w.setToolTip(opts['tip'])
     
     self.defaultBtn = QtGui.QPushButton()
     self.defaultBtn.setFixedWidth(20)
     self.defaultBtn.setFixedHeight(20)
     modDir = os.path.dirname(__file__)
     self.defaultBtn.setIcon(QtGui.QIcon(os.path.join(modDir, 'default.png')))
     self.defaultBtn.clicked.connect(self.defaultClicked)
     
     self.displayLabel = QtGui.QLabel()
     
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(2)
     layout.addWidget(w)
     layout.addWidget(self.displayLabel)
     layout.addWidget(self.defaultBtn)
     self.layoutWidget = QtGui.QWidget()
     self.layoutWidget.setLayout(layout)
     
     if w.sigChanged is not None:
         w.sigChanged.connect(self.widgetValueChanged)
         
     if hasattr(w, 'sigChanging'):
         w.sigChanging.connect(self.widgetValueChanging)
         
     ## update value shown in widget. 
     self.valueChanged(self, opts['value'], force=True)
Ejemplo n.º 17
0
 def treeWidgetChanged(self):
     ParameterItem.treeWidgetChanged(self)
     if self.addItem is not None:
         self.treeWidget().setItemWidget(self.addItem, 0, self.addWidgetBox)
         self.treeWidget().setFirstItemColumnSpanned(self.addItem, True)
Ejemplo n.º 18
0
 def treeWidgetChanged(self):
     ParameterItem.treeWidgetChanged(self)
     if self.addItem is not None:
         self.treeWidget().setItemWidget(self.addItem, 0, self.addWidgetBox)
         self.treeWidget().setFirstItemColumnSpanned(self.addItem, True)
Ejemplo n.º 19
0
 def addChild(self, child):  ## make sure added childs are actually inserted before add btn
     if self.addItem is not None:
         ParameterItem.insertChild(self, self.childCount()-1, child)
     else:
         ParameterItem.addChild(self, child)