Beispiel #1
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
Beispiel #2
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)
Beispiel #3
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
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
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)
    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()')
Beispiel #8
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_())