Ejemplo n.º 1
0
 def hideEvent(self, event):
     TaurusValue.hideEvent(self, event)
     try:
         self.getModelObj().getParentObj().getAttribute(
             'Value').disablePolling()
     except:
         pass
Ejemplo n.º 2
0
 def showEvent(self, event):
     TaurusValue.showEvent(self, event)
     try:
         self.getModelObj().getParentObj().getAttribute(
             'Value').enablePolling(force=True)
     except:
         pass
Ejemplo n.º 3
0
 def __init__(self, parent=None, designMode=False):
     TaurusValue.__init__(self, parent=parent, designMode=designMode)
     self.setLabelWidgetClass(LabelWidgetDragsDeviceAndAttribute)
     self.setLabelConfig('dev_alias')
     self.setReadWidgetClass(PoolIORegisterReadWidget)
     self.setWriteWidgetClass(PoolIORegisterWriteWidget)
     self.ioreg_dev = None
Ejemplo n.º 4
0
 def __init__(self, parent=None, designMode=False):
     TaurusValue.__init__(self, parent=parent, designMode=designMode)
     self.setLabelWidgetClass(PoolChannelTVLabelWidget)
     self.setWriteWidgetClass(None)
     self.setUnitsWidgetClass(PoolChannelTVUnitsWidget)
     self.setExtraWidgetClass(PoolChannelTVExtraWidget)
     self.channel_dev = None
Ejemplo n.º 5
0
 def __init__(self, parent=None, designMode=False):
     TaurusValue.__init__(self, parent=parent, designMode=designMode)
     self.setLabelWidgetClass(LabelWidgetDragsDeviceAndAttribute)
     self.setLabelConfig('dev_alias')
     self.setReadWidgetClass(PoolIORegisterReadWidget)
     self.setWriteWidgetClass(PoolIORegisterWriteWidget)
     self.ioreg_dev = None
Ejemplo n.º 6
0
def test_label_case_sensitivity(qtbot, caplog, taurus_test_ds):
    """Verify that case is respected of in the label widget"""
    with check_taurus_deprecations(caplog, expected=0):
        w = TaurusValue()
        qtbot.addWidget(w)
        w.setModel("tango:{}/MIXEDcase".format(taurus_test_ds))

        def _ok():
            assert w.labelWidget().text() == "MIXEDcase"

        qtbot.waitUntil(_ok, timeout=3200)
Ejemplo n.º 7
0
    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent)

        self.setLayout(Qt.QHBoxLayout())

        # put a widget with a TaurusValue
        w = Qt.QWidget()
        w.setLayout(Qt.QGridLayout())
        self._TaurusValue = TaurusValue(parent=w, designMode=designMode)
        self._TaurusValue.setLabelWidgetClass(
            LabelWidgetDragsDeviceAndAttribute)
        self._TaurusValue.setLabelConfig('<dev_alias>')
        self.layout().addWidget(w)

        #...and a dev button next to the widget
        self._devButton = TaurusDevButton(parent=self, designMode=designMode)
        self._devButton.setText('')
        self.layout().addWidget(self._devButton)

        self.modelChanged.connect(self._updateTaurusValue)
Ejemplo n.º 8
0
class PoolChannel(TaurusWidget):
    """ A widget that displays and controls a pool channel device
    
    .. seealso:: :class:`PoolChannelTV`
    """

    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent)

        self.setLayout(Qt.QHBoxLayout())

        # put a widget with a TaurusValue
        w = Qt.QWidget()
        w.setLayout(Qt.QGridLayout())
        self._TaurusValue = TaurusValue(parent=w, designMode=designMode)
        self._TaurusValue.setLabelWidgetClass(LabelWidgetDragsDeviceAndAttribute)
        self._TaurusValue.setLabelConfig("dev_alias")
        self.layout().addWidget(w)

        # ...and a dev button next to the widget
        self._devButton = TaurusDevButton(parent=self, designMode=designMode)
        self._devButton.setText("")
        self.layout().addWidget(self._devButton)

        self.connect(self, Qt.SIGNAL("modelChanged(const QString &)"), self._updateTaurusValue)

    def _updateTaurusValue(self):
        m = self.getModelName()
        self._TaurusValue.setModel("%s/value" % m)
        self._devButton.setModel(m)
Ejemplo n.º 9
0
class PoolChannel(TaurusWidget):
    ''' A widget that displays and controls a pool channel device

    .. seealso:: :class:`PoolChannelTV`
    '''
    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent)

        self.setLayout(Qt.QHBoxLayout())

        # put a widget with a TaurusValue
        w = Qt.QWidget()
        w.setLayout(Qt.QGridLayout())
        self._TaurusValue = TaurusValue(parent=w, designMode=designMode)
        self._TaurusValue.setLabelWidgetClass(
            LabelWidgetDragsDeviceAndAttribute)
        self._TaurusValue.setLabelConfig('<dev_alias>')
        self.layout().addWidget(w)

        #...and a dev button next to the widget
        self._devButton = TaurusDevButton(parent=self, designMode=designMode)
        self._devButton.setText('')
        self.layout().addWidget(self._devButton)

        self.modelChanged.connect(self._updateTaurusValue)

    def _updateTaurusValue(self):
        m = self.getModelName()
        self._TaurusValue.setModel("%s/value" % m)
        self._devButton.setModel(m)
Ejemplo n.º 10
0
    def build_widgets(self, values, show_labels=False, width=240, height=20, value_width=120):
        widgets_matrix = []
        for row in values:
            widgets_row = []
            for cell in row:
                cell_frame = self.create_frame_with_gridlayout()
                count = 0
                for synoptic in sorted(cell):
                    self.debug("processing synoptic %s" % synoptic)
                    name = model = synoptic

                    self.debug('Creating TaurusValue with model =  %s' % model)
                    synoptic_value = TaurusValue(cell_frame)
                    self.modelsQueue.put((synoptic_value, model))
                    synoptic_value.itemClicked.connect(self.itemClicked)

                    if self.hideLabels:
                        synoptic_value.setLabelWidgetClass(None)
                    else:
                        # DO NOT DELETE THIS LINE!!!
                        synoptic_value.setLabelConfig('label')
                    cell_frame.layout().addWidget(synoptic_value, count, 0)
                    self._widgets_list.append(synoptic_value)
                    count += 1

                # Done in this way as TauValue.mousePressEvent are never called
                def mousePressEvent(event, obj):
                    # print 'In cell clicked'
                    targets = set(str(child.getModelName()) for child in obj.children()
                                  if hasattr(child, 'underMouse') and child.underMouse() and hasattr(child, 'getModelName'))
                    [obj.itemClicked.emit(t)
                     for t in targets]

                cell_frame.mousePressEvent = partial(
                    mousePressEvent, obj=cell_frame)
                cell_frame.itemClicked.connect(self.itemClicked)

                widgets_row.append(cell_frame)
            widgets_matrix.append(widgets_row)
        return widgets_matrix
Ejemplo n.º 11
0
    def build_widgets(self,
                      values,
                      show_labels=False,
                      width=240,
                      height=20,
                      value_width=120):
        widgets_matrix = []
        for row in values:
            widgets_row = []
            for cell in row:
                cell_frame = self.create_frame_with_gridlayout()
                cell_frame.itemClicked.connect(self.onItemClicked)
                count = 0
                for synoptic in sorted(cell):
                    self.debug("processing synoptic %s" % synoptic)
                    name = model = synoptic

                    self.debug('Creating TaurusValue with model =  %s' % model)
                    synoptic_value = TaurusValue(cell_frame)
                    self.modelsQueue.put((synoptic_value, model))

                    if self.hideLabels:
                        synoptic_value.setLabelWidgetClass(None)
                    else:
                        # DO NOT DELETE THIS LINE!!!
                        synoptic_value.setLabelConfig('label')
                    cell_frame.layout().addWidget(synoptic_value, count, 0)
                    self._widgets_list.append(synoptic_value)
                    count += 1

                widgets_row.append(cell_frame)
            widgets_matrix.append(widgets_row)
        return widgets_matrix
Ejemplo n.º 12
0
def test_taurusvalue_subwidget_texts(qtbot, caplog):
    """Checks the texts for scalar attributes"""

    model = "eval:@a=taurus.core.evaluation.test.res.mymod.MyClass()/a.foo"
    expected = ("a.foo", "123", "123", "m")
    depr = 0

    with check_taurus_deprecations(caplog, expected=depr):
        w = TaurusValue()
        qtbot.addWidget(w)
        w.setModel(model)

        def _ok():
            got = (
                str(w.labelWidget().text()),
                str(w.readWidget().text()),
                str(w.writeWidget().displayText()),
                str(w.unitsWidget().text()),
            )
            assert got == expected

        qtbot.waitUntil(_ok, timeout=3200)
Ejemplo n.º 13
0
    def build_widgets(self,
                      values,
                      show_labels=False,
                      width=240,
                      height=20,
                      value_width=120):
        widgets_matrix = []
        for row in values:
            widgets_row = []
            for cell in row:
                cell_frame = self.create_frame_with_gridlayout()
                count = 0
                for synoptic in sorted(cell):
                    self.debug("processing synoptic %s" % synoptic)
                    name = model = synoptic

                    self.debug('Creating TaurusValue with model =  %s' % model)
                    synoptic_value = TaurusValue(cell_frame)
                    self.modelsQueue.put((synoptic_value, model))
                    QtCore.QObject.connect(
                        synoptic_value, QtCore.SIGNAL("itemClicked(QString)"),
                        self.itemClicked)

                    if self.hideLabels:
                        synoptic_value.setLabelWidgetClass(None)
                    else:
                        # DO NOT DELETE THIS LINE!!!
                        synoptic_value.setLabelConfig('label')
                    cell_frame.layout().addWidget(synoptic_value, count, 0)
                    self._widgets_list.append(synoptic_value)
                    count += 1

                # Done in this way as TauValue.mousePressEvent are never called
                def mousePressEvent(event, obj):
                    # print 'In cell clicked'
                    targets = set(
                        str(child.getModelName()) for child in obj.children()
                        if hasattr(child, 'underMouse') and child.underMouse()
                        and hasattr(child, 'getModelName'))
                    [
                        obj.emit(Qt.SIGNAL("itemClicked(QString)"), t)
                        for t in targets
                    ]

                cell_frame.mousePressEvent = partial(mousePressEvent,
                                                     obj=cell_frame)
                QtCore.QObject.connect(cell_frame,
                                       QtCore.SIGNAL("itemClicked(QString)"),
                                       self.itemClicked)

                widgets_row.append(cell_frame)
            widgets_matrix.append(widgets_row)
        return widgets_matrix
Ejemplo n.º 14
0
def test_bug126(qtbot, caplog):
    """Verify that case is not lost when customizing a label (bug#126)"""
    with check_taurus_deprecations(caplog, expected=0):
        w = TaurusValue()
        qtbot.addWidget(w)
        w.setModel("tango:sys/tg_test/1/double_scalar")
        label = "MIXEDcase"
        w.setLabelConfig(label)

        def _ok():
            assert w.labelWidget().text() == label

        qtbot.waitUntil(_ok, timeout=3200)
Ejemplo n.º 15
0
    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent)

        self.setLayout(Qt.QHBoxLayout())

        # put a widget with a TaurusValue
        w = Qt.QWidget()
        w.setLayout(Qt.QGridLayout())
        self._TaurusValue = TaurusValue(parent=w, designMode=designMode)
        self._TaurusValue.setLabelWidgetClass(LabelWidgetDragsDeviceAndAttribute)
        self._TaurusValue.setLabelConfig("dev_alias")
        self.layout().addWidget(w)

        # ...and a dev button next to the widget
        self._devButton = TaurusDevButton(parent=self, designMode=designMode)
        self._devButton.setText("")
        self.layout().addWidget(self._devButton)

        self.connect(self, Qt.SIGNAL("modelChanged(const QString &)"), self._updateTaurusValue)
Ejemplo n.º 16
0
 def setModel(self, model):
     TaurusValue.setModel(self, model)
     try:
         self.ioreg_dev = taurus.Device(model)
     except:
         return
Ejemplo n.º 17
0
 def showEvent(self, event):
     TaurusValue.showEvent(self, event)
     if self.ioreg_dev is not None:
         self.ioreg_dev.getAttribute('Value').enablePolling(force=True)
Ejemplo n.º 18
0
 def hideEvent(self, event):
     TaurusValue.hideEvent(self, event)
     if self.ioreg_dev is not None:
         self.ioreg_dev.getAttribute('Value').disablePolling()
Ejemplo n.º 19
0
 def setModel(self, model):
     if model is not None:
         # @todo: change this (it assumes tango naming!)
         model = "%s/value" % model
     TaurusValue.setModel(self, model)
Ejemplo n.º 20
0
 def __init__(self, parent=None, designMode=False):
     TaurusValue.__init__(self, parent=parent, designMode=designMode)
     self.setLabelWidgetClass(LabelWidgetDragsDeviceAndAttribute)
     self.setLabelConfig('<dev_alias>')
Ejemplo n.º 21
0
 def hideEvent(self, event):
     TaurusValue.hideEvent(self, event)
     try:
         self.getModelObj().getParentObj().getAttribute("Value").disablePolling()
     except:
         pass
Ejemplo n.º 22
0
 def setModel(self, model):
     print("!!!!! IN DUMMYCW.SETMODEL", model)
     TaurusValue.setModel(self, model + '/double_scalar')
Ejemplo n.º 23
0
 def setModel(self, model):
     if model is not None:
         model = "%s/value" % model  # @todo: change this (it assumes tango naming!)
     TaurusValue.setModel(self, model)
Ejemplo n.º 24
0
 def showEvent(self, event):
     TaurusValue.showEvent(self, event)
     try:
         self.getModelObj().getParentObj().getAttribute("Value").enablePolling(force=True)
     except:
         pass
Ejemplo n.º 25
0
 def __init__(self, parent=None, designMode=False):
     TaurusValue.__init__(self, parent=parent, designMode=designMode)
     self.setLabelWidgetClass(LabelWidgetDragsDeviceAndAttribute)
     self.setLabelConfig("dev_alias")
Ejemplo n.º 26
0
    def generateTable(self,values):
        
        #thermocouples = thermocouples if thermocouples is not None else self.thermocouples
        self.setRowCount(len(values))
        self.setColumnCount(5)
        #self.vheaders = []
        self.offset = 0
        self.widgetbuffer = []
        
        for i,tc in enumerate(sorted(values)):
            #print 'setTableRow(%s,%s)'%(i,tc)
            model,device,attribute,alias,archived,ok = tc
            model,device,attribute,alias = map(str.upper,(model,device,attribute,alias))
            #self.vheaders.append(model)
            def ITEM(m,model='',size=0):
                q = fn.qt.Draggable(Qt.QLabel)(m)
                if size is not 0:
                    q.setMinimumWidth(size) #(.7*950/5.)
                q._model = model
                q._archived = archived
                q.setDragEventCallback(lambda s=q:s._model)
                return q
            ###################################################################
            qf = Qt.QFrame()
            qf.setLayout(Qt.QGridLayout())
            qf.setMinimumWidth(self.SIZES[0])
            qf.setSizePolicy(Qt.QSizePolicy.Expanding,Qt.QSizePolicy.Fixed)
            #Order changed, it is not clear if it has to be done before or after adding TaurusValue selfect
            self.setCellWidget(i+self.offset,0,qf) 
            
            #print('Adding item: %s, %s, %s, %s, %s' % (model,device,attribute,alias,archived))
            if ok:
                tv = TaurusValue() #TaurusValueLabel()
                qf.layout().addWidget(tv,0,0)
                tv.setParent(qf)
            else:
                self.setItem(i+self.offset,0,ITEM(model,model))
                
            devlabel = ITEM(device,model,self.SIZES[1])
            self.setItem(i+self.offset,1,devlabel)
            self.setItem(i+self.offset,2,ITEM(attribute,model,self.SIZES[2]))
            self.setItem(i+self.offset,3,ITEM(alias,model,self.SIZES[3]))

            from PyTangoArchiving.widget.panel import showArchivingModes,show_history
            if archived:
              active = self.reader.is_attribute_archived(model,active=True)
              txt = '/'.join(a.upper() if a in active else a for a in archived)
            else:
              txt = '...'
            q = Qt.QPushButton(txt)
            q.setFixedWidth(self.SIZES[-2])
            q.setToolTip("""%s<br><br><pre>
              'HDB' : Archived and updated, push to export values
              'hdb' : Archiving stopped, push to export values
              '...' : Not archived
              </pre>"""%txt)
            self.connect(q, Qt.SIGNAL("pressed ()"), 
                lambda a=self.reader.get_attribute_alias(model),o=q: 
                 setattr(q,'w',show_history(a))) #showArchivingModes(a,parent=self)))
            self.setItem(i+self.offset,4,q)
            
            qc = Qt.QCheckBox()
            qc.setFixedWidth(self.SIZES[-1])
            self.setItem(i+self.offset,5,qc,1,1,Qt.Qt.AlignCenter,model)

            if ok:
                #print('Setting Model %s'%model)
                #ADDING WIDGETS IN BACKGROUND DIDN'T WORKED, I JUST CAN SET MODELS FROM THE WORKER
                try:
                    if self.worker:
                        self.worker.put([(lambda w=tv,m=model:w.setModel(m))])
                        #print 'worker,put,%s'%str(model)
                    else:
                        tv.setModel(model)
                except: 
                    print traceback.format_exc()
                self.models.append(tv)
                
            #self.widgetbuffer.extend([qf,self.itemAt(i+self.offset,1),self.itemAt(i+self.offset,2),self.itemAt(i+self.offset,3),self.itemAt(i+self.offset,4)])
            fn.threads.Event().wait(.02)
            
        if len(values):
            def setup(o=self):
                [o.setRowHeight(i,20) for i in range(o.rowCount())]
                #o.setColumnWidth(0,350)
                o.update()
                o.repaint()
                #print o.rowCount()
                o.show()
                
            setup(self)
            
        if self.worker:
            print( '%s.next()' % (self.worker) )
            self.worker.next()
            
        #threading.Event().wait(10.)
        tracer('Out of generateTable()')
Ejemplo n.º 27
0
import sys
from taurus.external.qt import Qt
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.panel import TaurusValue

app = TaurusApplication(sys.argv)
panel = Qt.QWidget()
layout = Qt.QGridLayout()
panel.setLayout(layout)

w = TaurusValue(panel)
layout.addWidget(w)
w.model = 'sys/tg_test/1/double_scalar'

panel.show()
sys.exit(app.exec_())
Ejemplo n.º 28
0
 def setModel(self, model):
     TaurusValue.setModel(self, model)
     if model == "" or model is None:
         return
     self.readWidget().setModel(model + "/Value")
     self.channel_dev = taurus.Device(model)
Ejemplo n.º 29
0
 def setModel(self, model):
     print "!!!!! IN DUMMYCW.SETMODEL", model
     TaurusValue.setModel(self, model + '/double_scalar')
Ejemplo n.º 30
0
 def showEvent(self, event):
     TaurusValue.showEvent(self, event)
     if self.ioreg_dev is not None:
         self.ioreg_dev.getAttribute('Value').enablePolling(force=True)
Ejemplo n.º 31
0
 def setModel(self, model):
     TaurusValue.setModel(self, model)
     try:
         self.ioreg_dev = taurus.Device(model)
     except:
         return
Ejemplo n.º 32
0
    def generateTable(self, values):

        #thermocouples = thermocouples if thermocouples is not None else self.thermocouples
        self.setRowCount(len(values))
        self.setColumnCount(5)
        #self.vheaders = []
        self.offset = 0
        self.widgetbuffer = []

        for i, tc in enumerate(sorted(values)):
            #print 'setTableRow(%s,%s)'%(i,tc)
            model, device, attribute, alias, archived, ok = tc
            model, device, attribute, alias = map(
                str.upper, (model, device, attribute, alias))

            #self.vheaders.append(model)
            def ITEM(m, model='', size=0):
                q = fandango.qt.Draggable(Qt.QLabel)(m)
                if size is not 0:
                    q.setMinimumWidth(size)  #(.7*950/5.)
                q._model = model
                q._archived = archived
                q.setDragEventCallback(lambda s=q: s._model)
                return q

            ###################################################################
            qf = Qt.QFrame()
            qf.setLayout(Qt.QGridLayout())
            qf.setMinimumWidth(self.SIZES[0])
            qf.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed)
            #Order changed, it is not clear if it has to be done before or after adding TaurusValue selfect
            self.setCellWidget(i + self.offset, 0, qf)

            #print('Adding item: %s, %s, %s, %s, %s' % (model,device,attribute,alias,archived))
            if ok:
                tv = TaurusValue()  #TaurusValueLabel()
                qf.layout().addWidget(tv, 0, 0)
                tv.setParent(qf)
            else:
                self.setItem(i + self.offset, 0, ITEM(model, model))

            devlabel = ITEM(device, model, self.SIZES[1])
            self.setItem(i + self.offset, 1, devlabel)
            self.setItem(i + self.offset, 2,
                         ITEM(attribute, model, self.SIZES[2]))
            self.setItem(i + self.offset, 3, ITEM(alias, model, self.SIZES[3]))

            from PyTangoArchiving.widget.panel import showArchivingModes, show_history
            if archived:
                active = self.reader.is_attribute_archived(model, active=True)
                txt = '/'.join(a.upper() if a in active else a
                               for a in archived)
            else:
                txt = '...'
            q = Qt.QPushButton(txt)
            q.setFixedWidth(self.SIZES[-2])
            q.setToolTip("""%s<br><br><pre>
              'HDB' : Archived and updated, push to export values
              'hdb' : Archiving stopped, push to export values
              '...' : Not archived
              </pre>""" % txt)
            self.connect(q,
                         Qt.SIGNAL("pressed ()"),
                         lambda a=self.reader.get_attribute_alias(
                             model), o=q: setattr(q, 'w', show_history(a))
                         )  #showArchivingModes(a,parent=self)))
            self.setItem(i + self.offset, 4, q)

            qc = Qt.QCheckBox()
            qc.setFixedWidth(self.SIZES[-1])
            self.setItem(i + self.offset, 5, qc, 1, 1, Qt.Qt.AlignCenter,
                         model)

            if ok:
                #print('Setting Model %s'%model)
                #ADDING WIDGETS IN BACKGROUND DIDN'T WORKED, I JUST CAN SET MODELS FROM THE WORKER
                try:
                    if self.worker:
                        self.worker.put([(lambda w=tv, m=model: w.setModel(m))
                                         ])
                        #print 'worker,put,%s'%str(model)
                    else:
                        tv.setModel(model)
                except:
                    print traceback.format_exc()
                self.models.append(tv)

            #self.widgetbuffer.extend([qf,self.itemAt(i+self.offset,1),self.itemAt(i+self.offset,2),self.itemAt(i+self.offset,3),self.itemAt(i+self.offset,4)])
            fandango.threads.Event().wait(.02)

        if len(values):

            def setup(o=self):
                [o.setRowHeight(i, 20) for i in range(o.rowCount())]
                #o.setColumnWidth(0,350)
                o.update()
                o.repaint()
                #print o.rowCount()
                o.show()

            setup(self)

        if self.worker:
            print('%s.next()' % (self.worker))
            self.worker.next()

        #threading.Event().wait(10.)
        tracer('Out of generateTable()')
Ejemplo n.º 33
0
 def hideEvent(self, event):
     TaurusValue.hideEvent(self, event)
     if self.ioreg_dev is not None:
         self.ioreg_dev.getAttribute('Value').disablePolling()