Exemple #1
0
 def get_attrs_form(self, device, form=None, filters=None, parent=None):
     filters = filters or get_regexp_dict(
         TaurusDevicePanel._attribute_filter, device, ['.*'])
     self.trace('In TaurusDevicePanel.get_attrs_form(%s,%s)' %
                (device, filters))
     allattrs = sorted(
         str(a) for a in taurus.Device(device).get_attribute_list()
         if str(a).lower() not in ('state', 'status'))
     attrs = []
     for a in filters:
         for t in allattrs:
             if a and searchCl(a.strip(), t.strip()):
                 aname = '%s/%s' % (device, t)
                 if aname not in attrs:
                     attrs.append(aname)
     if attrs:
         #self.trace( 'Matching attributes are: %s' % str(attrs)[:100])
         if form is None:
             form = TaurusForm(parent)
         elif hasattr(form, 'setModel'):
             form.setModel([])
         # Configuring the TauForm:
         form.setWithButtons(False)
         form.setWindowTitle(device)
         try:
             form.setModel(attrs)
         except Exception:
             self.warning(
                 'TaurusDevicePanel.ERROR: Unable to setModel for TaurusDevicePanel.attrs_form!!: %s'
                 % traceback.format_exc())
         return form
     else:
         return None
Exemple #2
0
 def get_attrs_form(self, device, form=None, filters=None, parent=None):
     filters = filters or get_regexp_dict(
         TaurusDevicePanel._attribute_filter, device, ['.*'])
     self.trace('In TaurusDevicePanel.get_attrs_form(%s,%s)' %
                (device, filters))
     allattrs = sorted(str(a) for a in taurus.Device(
         device).get_attribute_list() if str(a).lower() not in ('state', 'status'))
     attrs = []
     for a in filters:
         for t in allattrs:
             if a and searchCl(a.strip(), t.strip()):
                 aname = '%s/%s' % (device, t)
                 if aname not in attrs:
                     attrs.append(aname)
     if attrs:
         #self.trace( 'Matching attributes are: %s' % str(attrs)[:100])
         if form is None:
             form = TaurusForm(parent)
         elif hasattr(form, 'setModel'):
             form.setModel([])
         # Configuring the TauForm:
         form.setWithButtons(False)
         form.setWindowTitle(device)
         try:
             form.setModel(attrs)
         except Exception:
             self.warning(
                 'TaurusDevicePanel.ERROR: Unable to setModel for TaurusDevicePanel.attrs_form!!: %s' % traceback.format_exc())
         return form
     else:
         return None
Exemple #3
0
class VaccaSearchForm(TaurusWidget):
    """
    Form with an embedded search bar that can be used to set the models
    
    The preffix and suffix arguments can be used to limit the search
    """
    def __init__(self, preffix='', suffix='', labels=False, parent=None):
        TaurusWidget.__init__(self, parent)
        self.preffix = preffix
        self.suffix = suffix
        self.labels = labels
        if preffix or suffix:
            self.setWindowTitle('%s ... %s' % (preffix, suffix))
        self.setLayout(Qt.QVBoxLayout())
        self.bar = Qt.QWidget(self)
        self.search = Qt.QLineEdit()
        self.search.setText('... type to search for attributes ...')
        self.button = Qt.QPushButton('Load')
        self.connect(self.button, Qt.SIGNAL("pressed()"), self.apply_search)
        self.bar.setLayout(Qt.QHBoxLayout())
        self.bar.layout().addWidget(self.search)
        self.bar.layout().addWidget(self.button)
        self.layout().addWidget(self.bar)
        self.form = TaurusForm(self)
        self.layout().addWidget(self.form)

    def apply_search(self):
        signs = "==|=|<|>"
        txt = str(self.search.text() or '*')
        if fandango.clsearch(signs, txt):
            t = fandango.re.split(signs, txt, 1)[0]
            txt, formula = t, txt.replace(t, '')
        else:
            formula = ''
        txt = txt.replace(' ', '*').strip()
        txt = self.preffix + txt + self.suffix
        model = fandango.get_matching_attributes(txt)
        if self.labels and '/' in txt:
            dev, attr = txt.rsplit('/', 1)
            model.extend(
                fandango.tango.get_matching_device_attribute_labels(
                    dev, attr).keys())
        if formula and model:
            nm = []
            for m in model:
                try:
                    f = '%s %s' % (fandango.read_attribute(m), formula)
                    if eval(f):
                        nm.append(m)
                except:
                    pass
            model = nm
        self.form.setModel(model)
Exemple #4
0
 def __init__(self, preffix='', suffix='', labels=False, parent=None):
     TaurusWidget.__init__(self, parent)
     self.preffix = preffix
     self.suffix = suffix
     self.labels = labels
     if preffix or suffix:
         self.setWindowTitle('%s ... %s' % (preffix, suffix))
     self.setLayout(Qt.QVBoxLayout())
     self.bar = Qt.QWidget(self)
     self.search = Qt.QLineEdit()
     self.button = Qt.QPushButton('Load')
     self.connect(self.button, Qt.SIGNAL("pressed()"), self.apply_search)
     self.bar.setLayout(Qt.QHBoxLayout())
     self.bar.layout().addWidget(self.search)
     self.bar.layout().addWidget(self.button)
     self.layout().addWidget(self.bar)
     self.form = TaurusForm(self)
     self.layout().addWidget(self.form)