Beispiel #1
0
        self.whigh.setValue(val[1])

    def limitsChanged(self, param, limits):
        """Called when the parameter's limits have changed"""
        # Do we need this? copied from example
        ParameterItem.limitsChanged(self, param, limits)

        self.wlow.setOpts(bounds=limits)
        self.whigh.setOpts(bounds=limits)


class RangeParameter(Parameter):
    itemClass = RangeParameterItem


registerParameterType('range', RangeParameter, override=True)


class RangeParameterGraphItem(RangeParameterItem):
    def makeWidget(self):
        l = self.makeLayout()

        graphIcon = QtGui.QIcon()
        graphIcon.addFile(':/images/wavelimits.png', state=QtGui.QIcon.On)
        graphIcon.addFile(':/images/wavelimitsoff.png', state=QtGui.QIcon.Off)

        self.graphBtn = QtGui.QPushButton()
        self.graphBtn.setFixedWidth(20)
        self.graphBtn.setFixedHeight(20)
        self.graphBtn.setIcon(graphIcon)
        self.graphBtn.setCheckable(True)
Beispiel #2
0
            }, {
                'title': 'Settings:',
                'name': 'params',
                'type': 'group',
                'children': params
            }],
            'removable':
            True,
            'renamable':
            False
        }

        self.addChild(child)


registerParameterType('groupmove', PresetScalableGroupMove, override=True)


class PresetScalableGroupDet(pTypes.GroupParameter):
    """
        =============== ==============
        **Attributes**    **Type**
        *opts*            dictionnary
        *options*         string list
        =============== ==============

        See Also
        --------
        pymodaq.daq_utils.daq_utils.make_enum
    """
    def __init__(self, **opts):
Beispiel #3
0
def generateLantzParams(tree, device, alias = None, group_prefix =''):
    """
    Generate a param group from a Lantz device
    """
    registerParameterType('feats', FeatParameter, override=True)
    registerParameterType('dictfeats', DictFeatParameter, override=True)
    for fname in device.feats.keys():
        fcurrent = device.feats[fname].feat

        #Build a path
        name = device.name if alias is None else alias
        path = '/' + name
        if group_prefix != '': '/' + group_prefix + path

        #Get the attr and the associated signal
        fattr = getattr(device, fname)
        fattr_changed =  getattr(device, fname+'_changed')

        #@TODO: Figure out if there is a less weird way of doing this...
        modifiers = next(fcurrent.modifiers.items())[1][MISSING]

        if type(fcurrent) == Feat:
            path += '/Feats/' + fname

            skip = False
            # if "Quantity" in str(type(fattr)): value = fattr.magnitude
            # else: value = fattr
            value = fattr

            feat = device.feats[fname]
            if not skip:
                tree.addParam(path, value = value, feat = feat, type='feats', target = device)
                w = list(tree[path].items)[0].widget
                connect_feat(w, device, feat_name=fname)
                try:
                    w.setValue(feat.instance.recall(fname))
                except:
                    pass

        elif type(fcurrent)==DictFeat:
            path += '/DictFeats/' + fname

            skip = False
            feat = device.feats[fname]
            df = feat.feat
            key = _dget(df.modifiers, device, fname)['keys'][0]
            value = fattr[key]
            # if "Quantity" in str(type(value)): value = value.magnitude
            # else: value = value

            if not skip:
                tree.addParam(path, value=value, feat=feat, type='dictfeats', target=device)
                w = list(tree[path].items)[0].widget
                #connect_feat(w, device, feat_name=fname)
                #w.setValue(feat.instance.recall(fname))



    for a_name in device.actions.keys():
        a_current = device.actions[a_name].action

        #Build a path
        name = device.name if alias is None else alias
        path = '/' + name + '/Actions/' + a_name
        if group_prefix != '': '/' + group_prefix + path

        a_attr = getattr(device, a_name)

        sig = signature(a_current.func).parameters

        if type(a_current) == Action:
            
            if len(sig.keys())==1 and 'self' in sig.keys():
                tree.addParam(path, None, type='action')
                tree[path].sigActivated.connect(_buildStaticFunction(a_attr))

            else:
                kwargs = dict()
                for input_name in sig.keys():
                    if input_name != 'self':
                        tree[path+'/'+input_name] = sig[input_name].default
                        kwargs[input_name] = tree[path+'/'+input_name]
                    tree.addParam(path + '/' + "Execute", None, type='action')
                    tree[path + '/' + "Execute"].sigActivated.connect(_buildKwargsFromWidgets(a_attr, **kwargs))
Beispiel #4
0
                param['show_pb'] = True

        child = {
            'title': f'Action {newindex:02d}',
            'name': f'action{newindex:02d}',
            'type': 'group',
            'removable': True,
            'children': params,
            'removable': True,
            'renamable': False
        }

        self.addChild(child)


registerParameterType('groupshortcut', ScalableGroupShortCut, override=True)


class ShortcutBox(QtWidgets.QDialog):
    def __init__(self):
        super().__init__()
        layout = QtWidgets.QVBoxLayout()
        self.setLayout(layout)

        horwidget = QtWidgets.QWidget()
        layout.addWidget(horwidget)
        hor_layout = QtWidgets.QHBoxLayout()
        horwidget.setLayout(hor_layout)
        label = QtWidgets.QLabel('Pressed key on the keyboard:')
        self.label = QtWidgets.QLabel('')
        self.wlow.setValue(val[0])
        self.whigh.setValue(val[1])

    def limitsChanged(self, param, limits):
        """Called when the parameter's limits have changed"""
        # Do we need this? copied from example
        ParameterItem.limitsChanged(self, param, limits)

        self.wlow.setOpts(bounds=limits)
        self.whigh.setOpts(bounds=limits)


class RangeParameter(Parameter):
    itemClass = RangeParameterItem

registerParameterType('range', RangeParameter, override=True)


class RangeParameterGraphItem(RangeParameterItem):
    def makeWidget(self):
        l = self.makeLayout()

        graphIcon = QtGui.QIcon()
        graphIcon.addFile(':/images/wavelimits.png', state=QtGui.QIcon.On)
        graphIcon.addFile(':/images/wavelimitsoff.png', state=QtGui.QIcon.Off)

        self.graphBtn = QtGui.QPushButton()
        self.graphBtn.setFixedWidth(20)
        self.graphBtn.setFixedHeight(20)
        self.graphBtn.setIcon(graphIcon)
        self.graphBtn.setCheckable(True)
Beispiel #6
0
from .slide import SliderSpinBox, SliderParameterItem
from .led import LedPushParameter, LedParameter
from .date import DateParameter, DateTimeParameter, TimeParameter
from .list import ListParameter
from .table import TableParameter
from .tableview import TableViewParameter, TableViewCustom
from .itemselect import ItemSelectParameter
from .filedir import FileDirParameter
from .text import PlainTextPbParameter
from .numeric import NumericParameter

from pyqtgraph.parametertree.Parameter import registerParameterType, registerParameterItemType

GroupParameterCustom = GroupParameter

registerParameterType('float', NumericParameter, override=True)
registerParameterType('int', NumericParameter, override=True)
registerParameterItemType('bool_push',
                          BoolPushParameterItem,
                          SimpleParameter,
                          override=True)
registerParameterItemType('pixmap',
                          PixmapParameterItem,
                          SimpleParameter,
                          override=True)
registerParameterItemType('pixmap_check',
                          PixmapCheckParameterItem,
                          SimpleParameter,
                          override=True)
registerParameterItemType('slide',
                          SliderParameterItem,
        self.wlow.setValue(val[0])
        self.whigh.setValue(val[1])

    def limitsChanged(self, param, limits):
        """Called when the parameter's limits have changed"""
        # Do we need this? copied from example
        ParameterItem.limitsChanged(self, param, limits)

        self.wlow.setOpts(bounds=limits)
        self.whigh.setOpts(bounds=limits)


class RangeParameter(Parameter):
    itemClass = RangeParameterItem

registerParameterType('range', RangeParameter, override=True)


class RangeParameterGraphItem(RangeParameterItem):
    def makeWidget(self):
        l = self.makeLayout()

        graphIcon = QtGui.QIcon()
        graphIcon.addFile(':/images/wavelimits.png', state=QtGui.QIcon.On)
        graphIcon.addFile(':/images/wavelimitsoff.png', state=QtGui.QIcon.Off)

        self.graphBtn = QtGui.QPushButton()
        self.graphBtn.setFixedWidth(20)
        self.graphBtn.setFixedHeight(20)
        self.graphBtn.setIcon(graphIcon)
        self.graphBtn.setCheckable(True)