本文整理汇总了Python中taurus.qt.qtgui.container.TaurusWidget.setModel方法的典型用法代码示例。如果您正苦于以下问题:Python TaurusWidget.setModel方法的具体用法?Python TaurusWidget.setModel怎么用?Python TaurusWidget.setModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taurus.qt.qtgui.container.TaurusWidget
的用法示例。
在下文中一共展示了TaurusWidget.setModel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setModel
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
def setModel(self, model):
'''
reimplemented from :class:`TaurusWidget`. A door device name is
expected as the model
'''
TaurusWidget.setModel(self, model)
if self.door is not None:
self.disconnect(self.door, Qt.SIGNAL('macroStatusUpdated'), self._statusUpdated)
self.disconnect(self.door, Qt.SIGNAL('resultUpdated'), self._resultUpdated)
# disable management of Door Tango States
self.door.getAttribute('State').removeListener(self.door_state_listener)
self.disconnect(self.door_state_listener, Qt.SIGNAL('doorStateChanged'), self._doorStateChanged)
self.door_state_listener = None
try: self.door = taurus.Device(model)
except: return
self.connect(self.door, Qt.SIGNAL('macroStatusUpdated'), self._statusUpdated)
self.connect(self.door, Qt.SIGNAL('resultUpdated'), self._resultUpdated)
# Manage Door Tango States
self.door_state_listener = DoorStateListener()
self.connect(self.door_state_listener, Qt.SIGNAL('doorStateChanged'), self._doorStateChanged)
self.door.getAttribute('State').addListener(self.door_state_listener)
示例2: setModel
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
def setModel(self, model):
oldModelObj = self.getModelObj()
if oldModelObj is not None:
self.disconnect(oldModelObj, Qt.SIGNAL("macrosUpdated"), self.macroComboBox.onMacrosUpdated)
TaurusWidget.setModel(self, model)
newModelObj = self.getModelObj()
self.connect(newModelObj, Qt.SIGNAL("macrosUpdated"), self.macroComboBox.onMacrosUpdated)
示例3: setModel
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
def setModel(self, model):
oldModelObj = self.getModelObj()
if oldModelObj is not None:
oldModelObj.macrosUpdated.disconnect(
self.macroComboBox.onMacrosUpdated)
TaurusWidget.setModel(self, model)
newModelObj = self.getModelObj()
newModelObj.macrosUpdated.connect(self.macroComboBox.onMacrosUpdated)
示例4: setModel
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
def setModel(self, model):
'''This implementation propagates the model to the read and write widgets.
You may reimplement it to do things like passing different models to each.
'''
if self.readWidget is not None:
self.readWidget.setModel(model)
if self.writeWidget is not None:
self.writeWidget.setModel(model)
TaurusWidget.setModel(self, model)
示例5: setModel
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
def setModel(self, model):
oldModelObj = self.getModelObj()
if oldModelObj is not None:
# TODO: check if macrosUpdated signal exists
oldModelObj.macrosUpdated.disconnect(
self.macroComboBox.onMacrosUpdated)
TaurusWidget.setModel(self, model)
newModelObj = self.getModelObj()
newModelObj.macrosUpdated.connect(
self.macroComboBox.onMacrosUpdated)
示例6: setModel
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
def setModel(self, model):
'''Reimplemented from :meth:`TaurusWidget.setModel`'''
TaurusWidget.setModel(self, model)
model_obj = self.getModelObj()
if model_obj.isWritable() and self.defaultWriteMode != "r":
self._writeMode = True
else:
self.defaultWriteMode = "r"
if model_obj is not None:
self._tableView._attr = model_obj
if model_obj.type in [DataType.Integer, DataType.Float]:
if self._writeMode:
try:
default_unit = str(model_obj.wvalue.units)
except AttributeError:
default_unit = ''
else:
default_unit = str(model_obj.rvalue.units)
# TODO: fill the combobox with the compatible units
self._units.addItem("%s" % default_unit)
self._units.setCurrentIndex(self._units.findText(default_unit))
self._units.setEnabled(False)
else:
self._units.setVisible(False)
raiseException = False
if model_obj.data_format == DataFormat._2D:
try:
dim_x, dim_y = numpy.shape(model_obj.rvalue)
except ValueError:
raiseException = True
elif model_obj.data_format == DataFormat._1D:
try:
dim_x, dim_y = len(model_obj.rvalue), 1
except ValueError:
raiseException = True
else:
raiseException = True
if raiseException:
raise Exception('rvalue is invalid')
self._tableView.setModel([dim_x, dim_y])
self.setWriteMode(self._writeMode)
self._label.setModel(model)
示例7: setModel
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
def setModel(self, model):
TaurusWidget.setModel(self, model)
self._ui.heartbeatRead.setModel("%s/HeartBeat" % (self.model))
self._ui.lockerRead.setModel("%s/Lock_Status" % (self.model))
self._ui.lockingRead.setModel("%s/Locking" % (self.model))
self._ui.lockingWrite.setModel("%s/Locking" % (self.model))
self._ui.lockingWrite.setAutoApply(True)
self._ui.lockingWrite.setForcedApply(False)
self._ui.stateRead.setModel("%s/state" % (self.model))
self._ui.statusRead.setModel("%s/status" % (self.model))
self._ui.statusRead.setBgRole(None)
self._ui.ResetState.setModel(model)
self._ui.ResetState.setCommand('ResetState')
self._ui.RestoreReadDB.setModel(model)
self._ui.RestoreReadDB.setCommand('RestoreReadDB')
self._ui.RestoreReadDB.setDangerMessage("This is an experimental "
"feature! Use with caution and"
" under your responsability.")
self._ui.forceWriteDB.setModel("%s/forceWriteDB" % (self.model))
示例8: Bug169_Test
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
class Bug169_Test(BaseWidgetTestCase, unittest.TestCase):
'''
Test bug169: See: http://sf.net/p/tauruslib/tickets/65/
(aka, Sradana's bug169)
.. seealso: :class:`taurus.qt.qtgui.test.base.BaseWidgetTestCase`
'''
_klass = TaurusLabel
def setUp(self):
BaseWidgetTestCase.setUp(self)
self._widget.setModel('sys/tg_test/1/double_scalar#label')
self._expectedModelClass = self._widget.getModelClass()
self._parent = TaurusWidget()
self._parent.setModel('sys/tg_test/1')
self._widget.setUseParentModel(True)
self._widget.setParent(self._parent)
def test_bug169(self):
'''Check if setModel works when using parent model'''
self._widget.setModel('/double_scalar#label')
self.assertMaxDeprecations(0)
def test_relativemodelclass(self):
'''Check consistency in modelClass when using parent model (re: bug169)
'''
try:
self._widget.setModel('/double_scalar#label')
finally:
mc = self._widget.getModelClass()
msg = ('getModelClass() inconsistency:\n expected: %s\n got: %s' %
(self._expectedModelClass, mc))
self.assertEqual(self._expectedModelClass, mc, msg)
self.assertMaxDeprecations(0)
示例9: setModel
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
def setModel(self, model, pixmap=None):
model, modelclass, raw = str(model).strip(), '', model
if model:
model = model and model.split()[0] or ''
modelclass = taurus.Factory().findObjectClass(model)
self.trace('In TaurusDevicePanel.setModel(%s(%s),%s)' %
(raw, modelclass, pixmap))
if model == self.getModel():
return
elif raw is None or not model or not modelclass:
if self.getModel():
self.detach()
return
elif issubclass(modelclass, TaurusAttribute):
# if model.lower().endswith('/state'):
model = model.rsplit('/', 1)[0] # TODO: Tango-centric
elif not issubclass(modelclass, TaurusDevice):
self.warning('TaurusDevicePanel accepts only Device models')
return
try:
taurus.Device(model).ping() # TODO: Tango-centric
if self.getModel():
self.detach() # Do not dettach previous model before pinging the new one (fail message will be shown at except: clause)
TaurusWidget.setModel(self, model)
self.setWindowTitle(str(model).upper())
model = self.getModel()
self._label.setText(model.upper())
font = self._label.font()
font.setPointSize(15)
self._label.setFont(font)
if pixmap is None and self.getIconMap():
for k, v in self.getIconMap().items():
if searchCl(k, model):
pixmap = v
if pixmap is not None:
# print 'Pixmap is %s'%pixmap
qpixmap = Qt.QPixmap(pixmap)
if qpixmap.height() > .9 * IMAGE_SIZE[1]:
qpixmap = qpixmap.scaledToHeight(.9 * IMAGE_SIZE[1])
if qpixmap.width() > .9 * IMAGE_SIZE[0]:
qpixmap = qpixmap.scaledToWidth(.9 * IMAGE_SIZE[0])
else:
logo = getattr(tauruscustomsettings, 'ORGANIZATION_LOGO',
"logos:taurus.png")
qpixmap = getCachedPixmap(logo)
self._image.setPixmap(qpixmap)
self._state.setModel(model + '/state') # TODO: Tango-centric
if hasattr(self, '_statelabel'):
self._statelabel.setModel(
model + '/state') # TODO: Tango-centric
self._status.setModel(model + '/status') # TODO: Tango-centric
try:
self._attrsframe.clear()
filters = get_regexp_dict(
TaurusDevicePanel._attribute_filter, model, ['.*'])
if hasattr(filters, 'keys'):
filters = filters.items() # Dictionary!
if filters and isinstance(filters[0], (list, tuple)): # Mapping
self._attrs = []
for tab, attrs in filters:
self._attrs.append(self.get_attrs_form(
device=model, filters=attrs, parent=self))
self._attrsframe.addTab(self._attrs[-1], tab)
else:
if self._attrs and isinstance(self._attrs, list):
self._attrs = self._attrs[0]
self._attrs = self.get_attrs_form(
device=model, form=self._attrs, filters=filters, parent=self)
if self._attrs:
self._attrsframe.addTab(self._attrs, 'Attributes')
if not TaurusDevicePanel.READ_ONLY:
self._comms = self.get_comms_form(model, self._comms, self)
if self._comms:
self._attrsframe.addTab(self._comms, 'Commands')
if SPLIT_SIZES:
self._splitter.setSizes(SPLIT_SIZES)
except:
self.warning(traceback.format_exc())
qmsg = Qt.QMessageBox(Qt.QMessageBox.Critical, '%s Error' %
model, '%s not available' % model, Qt.QMessageBox.Ok, self)
qmsg.setDetailedText(traceback.format_exc())
qmsg.show()
except:
self.warning(traceback.format_exc())
qmsg = Qt.QMessageBox(Qt.QMessageBox.Critical, '%s Error' %
model, '%s not available' % model, Qt.QMessageBox.Ok, self)
qmsg.show()
self.setWindowTitle(self.getModel())
return
示例10: TaurusWidget
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
from taurus.qt.qtgui.container import TaurusWidget
from taurus.qt.qtgui.display import TaurusLabel
from taurus.qt.qtgui.input import TaurusValueSpinBox
app = Qt.QApplication(sys.argv)
panel = TaurusWidget()
layout = Qt.QHBoxLayout()
panel.setLayout(layout)
w1 = TaurusLabel()
w2 = TaurusLabel()
w3 = TaurusValueSpinBox()
w4 = TaurusLabel()
layout.addWidget(w1)
layout.addWidget(w2)
layout.addWidget(w3)
layout.addWidget(w4)
w1.setUseParentModel(True)
w2.setUseParentModel(True)
w3.setUseParentModel(True)
w4.setUseParentModel(True)
panel.setModel('sys/taurustest/1')
w1.setModel('/position#label')
w2.setModel('/position')
w3.setModel('/position')
w4.setModel('/position#unit')
panel.show()
sys.exit(app.exec_())
示例11: TaurusCommandsForm
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
#.........这里部分代码省略.........
for row, c in enumerate(commands):
self.debug('Adding button for command %s' % c.cmd_name)
button = TaurusCommandButton(command=c.cmd_name, text=c.cmd_name)
layout.addWidget(button, row, 0)
button.setUseParentModel(True)
self._cmdWidgets.append(button)
button.commandExecuted.connect(self._onCommandExecuted)
if c.in_type != PyTango.CmdArgType.DevVoid:
self.debug('Adding arguments for command %s' % c.cmd_name)
pwidget = ParameterCB()
if c.cmd_name.lower() in self._defaultParameters:
for par in self._defaultParameters.get(c.cmd_name.lower(), []):
pwidget.addItem(par)
#pwidget.setEditable( (self._defaultParameters[c.cmd_name.lower()] or [''])[0] == '' )
if (self._defaultParameters[c.cmd_name.lower()] or [''])[0] == '':
pwidget.setEditable(True)
else:
pwidget.setEditable(False)
button.setParameters(self._defaultParameters[
c.cmd_name.lower()][0])
pwidget.editTextChanged.connect(button.setParameters)
pwidget.currentIndexChanged.connect(button.setParameters)
pwidget.activated.connect(button.setFocus)
button.commandExecuted.connect(pwidget.rememberCurrentText)
layout.addWidget(pwidget, row, 1)
self._paramWidgets.append(pwidget)
def _clearFrame(self):
'''destroys all widgets in the scroll area frame'''
self._frame = TaurusWidget(self)
self._frame.setLayout(Qt.QGridLayout())
# hack because useParentModel does not work!
self._frame.setModel(self.getModelName())
self._scrollArea.setWidget(self._frame)
self._cmdWidgets = []
self._paramWidgets = []
def _onCommandExecuted(self, result):
'''Slot called when the command is executed, to manage the output
:param result: return value from the command. The type depends on the command
'''
timestamp = datetime.now()
cmdbutton = self.sender()
output = '<i>%s</i><br>' % timestamp.strftime('%Y-%m-%d %H:%M:%S') +\
'<b>Command:</b> %s<br>' % cmdbutton.getCommand() +\
'<b>Pars:</b> %s<br>' % repr(cmdbutton.getParameters()) +\
'<b>Return Value:</b><br>%s' % str(result)
self._outputTE.append(output)
# ugly workaround for bug in html rendering in Qt
separator = '<table width=\"100%\"><tr><td><hr /></td></tr></table>'
# see http://lists.trolltech.com/qt-interest/2008-04/thread00224-0.html
self._outputTE.append(separator)
# self._outputTE.append('%s'%timestamp)
#self._outputTE.append('<b>Command:</b> "%s"'%cmdbutton.getCommand())
#self._outputTE.append('<b>Pars:</b> %s'%repr(cmdbutton.getParameters()))
#self._outputTE.append('<b>Return Value:</b><br>%s<hr>'%str(result))
def setSortKey(self, sortkey):
'''sets the method used to sort the commands (cmd_name by default)
:param sortkey: (callable) a function that takes a :class:`CommandInfo`
as argument and returns a key to use for sorting purposes
(e.g. the default sortKey is ``lambda x:x.cmd_name``)
'''
示例12: called
# 需要导入模块: from taurus.qt.qtgui.container import TaurusWidget [as 别名]
# 或者: from taurus.qt.qtgui.container.TaurusWidget import setModel [as 别名]
# Now, by adding the widgets to the layout we are actually reparenting them.
# The order in which we reparent determines success/failure:
# if we do m-->p and then c-->m, it works, but if we do it in the opposite
# order, we trigger the error.
# (i.e., if we had called "p.layout().addWidget(m)" it would work work)
m.layout().addWidget(c)
p.layout().addWidget(m)
# the problem arises because the Taurus ancestry of c is only checked when:
# a) c.setUseParentModel() is called (and it effectively changes something) or
# b) when c is Qt-reparented
##
# In this example, c is reparented before m, so when it checks for a Taurus
# ancestor, none is found. Then m is reparented and c now would find its right
# Taurus ancestor (p)... but c never gets notified!
# Manually calling c.recheckTaurusParent() after the parenting has changed is
# another way to work around this issue (you can test by uncommenting
# the following line):
# c.recheckTaurusParent()
p.setModel('sys/tg_test/1/state')
print 'p model:', p.getModelName()
print 'c model:', c.getModelName()
p.show()
sys.exit(app.exec_())