|
From: Carlos P. <cpa...@ce...> - 2016-01-28 11:33:51
|
I did a complete rework based on cfalcon's work and pushed it to
taurus4.
On Wed 2 December 2015 09:57:35 Carlos Pascual wrote:
> Hi, the changes seem ok to me, but the implementation has one problem:
>
> It assumesthat the "normal_name" returned by the validator is
> equivalent to the device name (and it psses it to setTable). But this
> is not always the case. The normal name may contain the DB name in it
> if it is not the default one.
>
> For example, in my system I have constrols02:10000 as my default DB,
> and the device cpascual/pysignalsimulator/1 is exported only in
> controls01 (not in controls02) then:
>
> This fails:
>
> ~~~~
> python taurusdevicepropertytable.py \
> tango://controls01:10000/cpascual/pysignalsimulator/1
> ~~~~
>
> This also fails:
>
> ~~~~
> devenv python taurusdevicepropertytable.py \
> --tango-host=controls01:10000 cpascual/pysignalsimulator/1
> ~~~~
>
> And this works:
>
> ~~~~
> TANGO_HOST=controls01:10000 python taurusdevicepropertytable.py \
> cpascual/pysignalsimulator/1
> ~~~~
>
> Apart from this, simply running `python taurusdevicepropertytable.py`
> I get this exception (the widget seems to work anyway):
>
> ~~~~
> Traceback (most recent call last):
> File
> "/home/cpascual/src/taurus/lib/taurus/qt/qtgui/base/taurusbase.py",
> line 341, in filterEvent
> self.handleEvent(*evt)
> File
> "/home/cpascual/src/taurus/lib/taurus/qt/qtgui/base/taurusbase.py",
> line 1257, in handleEvent
> self._setText(text)
> TypeError: setText() takes exactly 4 arguments (2 given)
>
> ~~~~
>
> Finally,
> it would be nice if you test the implementation on taurus4-preview as
> well (I haven't yet)
>
> Can you please resubmit addressing this problems?
>
> Note: if it is too much work, I think the current implementation is
> more or less ok and can be applied with just a TODO notifying of the
> currently known limitations
>
> Cheers,
>
> Carlos
>
> On Wed 11 November 2015 11:56:56 cfalcon wrote:
> > setModel of taurus.qt.qtgui.table.TaurusPropTable does not work.
> >
> > TaurusPropTable uses the inherit setModel method of TaurusBaseWidget
> > class that does not cover the funcionality of this widget.
> >
> > Implement a setModel method acording the specifications provided
> > by S.Rubio.
> > ---
> >
> > .../qt/qtgui/table/taurusdevicepropertytable.py | 57
> >
> > ++++++++++++++-------- 1 file changed, 38 insertions(+), 19
> > deletions(-)
> >
> > diff --git a/lib/taurus/qt/qtgui/table/taurusdevicepropertytable.py
> > b/lib/taurus/qt/qtgui/table/taurusdevicepropertytable.py index
> > 9901ec3..cc9722e 100644
> > --- a/lib/taurus/qt/qtgui/table/taurusdevicepropertytable.py
> > +++ b/lib/taurus/qt/qtgui/table/taurusdevicepropertytable.py
> > @@ -31,14 +31,15 @@ __all__ = ["TaurusPropTable"]
> >
> > from taurus.external.qt import Qt, QtCore, QtGui
> > from taurus.qt.qtgui.base import TaurusBaseWidget
> >
> > -import taurus.core
> > -import PyTango
> > +import taurus
> > +from taurus.core.taurusdevice import TaurusDevice
> >
> > class TaurusPropTable(QtGui.QTableWidget, TaurusBaseWidget):
> > '''
> > This widget will show a list of properties of device and the
> > list
> >
> > of values. @todo add a frame for Add, Delete and Refresh buttons!
> >
> > '''
> >
> > + # TODO This widget is Tango-centric
> >
> > __pyqtSignals__ = ("modelChanged(const QString &)",)
> >
> > def __init__(self, parent=None, designMode = False):
> > @@ -59,6 +60,14 @@ class TaurusPropTable(QtGui.QTableWidget,
> > TaurusBaseWidget):
> > #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
> > ~
> > -~-~-~- # TaurusBaseWidget over writing methods
> >
> > #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
> > ~
> > -~-~-~- + def setModel(self, model):
> > + name_validator = TaurusDevice.getNameValidator()
> > + TaurusBaseWidget.setModel(self, model)
> > + try:
> > + _, normal_name, _ = name_validator.getNames(model)
> > + self.setTable(normal_name)
> > + except ValueError:
> > + self.debug('Wrong model!! %s' %(model))
> >
> > def sizeHint(self):
> > return QtGui.QTableWidget.sizeHint(self)
> >
> > @@ -67,7 +76,7 @@ class TaurusPropTable(QtGui.QTableWidget,
> > TaurusBaseWidget): return QtGui.QTableWidget.minimumSizeHint(self)
> >
> > def getModelClass(self):
> > - return taurus.core.taurusdatabase.TaurusDatabase
> > + return TaurusDevice
> >
> > @classmethod
> >
> > def getQtDesignerPluginInfo(cls):
> > @@ -82,7 +91,7 @@ class TaurusPropTable(QtGui.QTableWidget,
> > TaurusBaseWidget):
> > #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
> > ~
> > -~-~-~-
> >
> > model = QtCore.pyqtProperty("QString",
> > TaurusBaseWidget.getModel,
> >
> > - TaurusBaseWidget.setModel,
> > + setModel,
> >
> > TaurusBaseWidget.resetModel)
> >
> > useParentModel = QtCore.pyqtProperty("bool",
> >
> > @@ -95,30 +104,37 @@ class TaurusPropTable(QtGui.QTableWidget,
> > TaurusBaseWidget):
> > #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
> > ~
> > -~-~-~-
> >
> > @QtCore.pyqtSignature("setTable(QString)")
> >
> > - def setTable(self,dev_name):
> >
> > + def setTable(self, dev_name):
> > '''
> > This method is used to connect TaurusPropTable widget with
> >
> > TaurusClassTable widget This method fill the table with the names of
> > properties and values for the device selected in the
> > TaurusClassTable
> > '''
> > -
> > QtCore.QObject.disconnect(self,QtCore.SIGNAL("cellChanged(int,int)")
> > ,
> > self.valueChanged) - self.db = PyTango.Database()
> > + QtCore.QObject.disconnect(self,
> > QtCore.SIGNAL("cellChanged(int, int)"), +
> >
> > self.valueChanged)
> >
> > + self.db = taurus.Database()
> >
> > dev_name = str(dev_name)
> >
> > - self.list_prop =
> > list(self.db.get_device_property_list(dev_name,'*')) +
> > self.list_prop = list(self.db.get_device_property_list(dev_name,
> > '*')) self.setRowCount(len(self.list_prop))
> >
> > for i in range(0,len(self.list_prop)):
> > elem = self.list_prop[i]
> > self.setText(elem,i,0)
> >
> > -
> > self.dictionary=self.db.get_device_property(dev_name,self.list_prop)
> > - self.debug('Getting %s properties: %s ->
> > %s'%(dev_name,self.list_prop,self.dictionary)) +
> > self.dictionary= self.db.get_device_property(dev_name, +
> >
> > self.list_prop) +
> >
> > self.debug('Getting %s properties: %s -> %s' %(dev_name, +
> >
> > self.list_prop, +
> >
> > self.dictionary)) value=self.dictionary[elem]
> > - self.debug('TaurusPropsTable: property %s is type
> > %s'%(elem,type(value))) - USE_TABLES=False
> > + self.debug('TaurusPropsTable: property %s is type %s'
> > %(elem, +
> >
> > type(value)) + )
> >
> > + USE_TABLES= False
> >
> > if USE_TABLES: self.setPropertyValue(value,i,1)
> >
> > else:
> > if not isinstance(value,str): #not something like
> > an
> >
> > string #if isinstance(value,list):#type(value) is list: heigh1 =
> > len(value)
> > - value = '\n'.join(str(v) for v in value) #
> > adding new lines in between elements in the list +
> > # adding new lines in between elements in the list +
> > value = '\n'.join(str(v) for v in value)
> > self.setText(str(value),i,1)
> >
> > self.updateStyle()
> >
> > @@ -372,12 +388,15 @@ class Delegate(QtGui.QItemDelegate):
> > return size
> >
> > if __name__ == '__main__':
> > - import sys,os
> > - app = QtGui.QApplication([])
> > + import sys
> > + from taurus.qt.qtgui.application import TaurusApplication
> > + app = TaurusApplication(app_name="TaurusDevice property table")
> >
> > widget = TaurusPropTable()
> >
> > - args = sys.argv[1:]
> > - if not args: args =
> > ['tango/admin/%s'%(os.environ['TANGO_HOST'].split(':')[0])] -
> > widget.setTable(sys.args)
> > + args = sys.argv
> > + if len(args) == 1:
> > + model = 'sys/tg_test/1'
> > + else:
> > + model = str(args[1])
> > + widget.setModel(model)
> >
> > widget.show()
> > app.exec_()
> >
> > -
--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
ALBA Synchrotron [http://www.albasynchrotron.es]
Carrer de la Llum 2-26
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpa...@ce...
Phone: +34 93 592 4428
+----------------------------------------------------+
|