def setModel(self, model): TaurusBaseWidget.setModel(self, model) plot = self.get_plot() if self.image is not None: self.disconnect(self.image.getSignaller(), Qt.SIGNAL("dataChanged"), self.update_cross_sections) plot.del_item(self.image) del self.image self.unregisterEvents() if model is None: return beamviewer = self.getPluginDevice('beamviewer') if not beamviewer: return image_attr = beamviewer.getAttribute('VideoImage') param = ImageParam() param.interpolation = 0 # None (nearest pixel) self.image = LimaVideoImageItem(param) self.image.setModel(image_attr) self.connect(self.image.getSignaller(), Qt.SIGNAL("dataChanged"), self.update_cross_sections) plot.add_item(self.image) self.registerEvents()
def setModel(self, m): # force to build another controller self._controller = None self._permanentText = None TaurusBaseWidget.setModel(self, m) if self.modelFragmentName: self.setFgRole(self.modelFragmentName)
def __init__(self, parent=None, designMode=False, taurusparam=None, toolbar=True, **kwargs): '''see :class:`guiqwt.plot.CurveDialog` for other valid initialization parameters''' CurveDialog.__init__(self, parent=parent, toolbar=toolbar, **kwargs) TaurusBaseWidget.__init__(self, 'TaurusTrendDialog') self.deprecated(rel='4.1', dep='TaurusTrendDialog', alt='TaurusTrend / taurus tpg trend launcher') self.setWindowFlags(Qt.Qt.Widget) self._designMode = designMode self._modelNames = CaselessList() from guiqwt.styles import style_generator self.style = style_generator() self.setSupportedMimeTypes( [TAURUS_MODEL_LIST_MIME_TYPE, TAURUS_ATTR_MIME_TYPE]) from taurus.qt.qtgui.extra_guiqwt.tools import TaurusModelChooserTool, AutoScrollTool self.add_tool(TaurusModelChooserTool, singleModel=False) self.add_tool(AutoScrollTool) self.setModifiableByUser(self._modifiableByUser) if taurusparam is None: taurusparam = TaurusTrendParam() self.defaultTaurusparam = taurusparam self.setContextMenuPolicy(Qt.Qt.CustomContextMenu) self.registerConfigDelegate(self.get_tool(AutoScrollTool))
def __init__(self, parent=None, designMode=False, toolbar=True, stackMode='deltatime', buffersize=512, options=None, **kwargs): '''see :class:`guiqwt.plot.ImageDialog` for other valid initialization parameters''' defaultOptions = dict(lock_aspect_ratio=False) if options is not None: defaultOptions.update(options) ImageDialog.__init__(self, parent=parent, toolbar=toolbar, options=defaultOptions, **kwargs) TaurusBaseWidget.__init__(self, "TaurusTrend2DDialog") self.trendItem = None self.buffersize = buffersize self._useArchiving = False self._stackMode = stackMode self.setStackMode(stackMode) self.setWindowFlags(Qt.Qt.Widget) # add some tools for toolklass in (TaurusModelChooserTool, AutoScrollTool): self.add_tool(toolklass) self.get_tool(TaurusModelChooserTool).singleModel = True self.setModifiableByUser(self._modifiableByUser) self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
def setModel(self, model): dev_name, self._image_attr_name = model.rsplit('/', 1) obj = self.getTaurusFactory().getDevice(dev_name) if obj is not None: obj.addImageAttrName(self._image_attr_name) TaurusBaseWidget.setModel(self, dev_name) self.setWindowTitle(self.getModel())
def __init__( self, parent=None, profile='spockdoor', use_model_from_profile=False, extensions=None, kernel='python3', **kw): RichJupyterWidget.__init__(self, parent=parent, **kw) TaurusBaseWidget.__init__(self) self.setObjectName(self.__class__.__name__) self.setModelInConfig(True) self._profile = profile self.use_model_from_profile = use_model_from_profile if extensions is None: extensions = [] extensions.insert( 0, "sardana.taurus.qt.qtgui.extra_sardana.qtspock_ext") self._extensions = extensions self._kernel_name = kernel self._macro_server_name = None self._macro_server_alias = None self._door_name = None self._door_alias = None self.kernel_manager = SpockKernelManager(kernel_name=kernel) self.kernel_manager.kernel_about_to_launch.connect( self._handle_kernel_lauched)
def setModel(self, m): TaurusBaseWidget.setModel(self, m) view, modelObj = self.viewWidget(), self.getModelObj() model = view.model() if model is None: return model.setDataSource(modelObj)
def updateStyle(self): if self.getShowQuality(): self.setAutoFillBackground(True) # TODO: get quality/state from model and update accordingly else: self.setAutoFillBackground(False) # TODO: restore colors TaurusBaseWidget.updateStyle(self)
def mousePressEvent(self, event): """ Records last event position to use it for DragEvents """ try: self.mousePos = event.scenePos().x(), event.scenePos().y() except: self.mousePos = event.x(), event.y() self.debug('MouseEvent received is not a GraphicsScene event, using raw position %s' % str( self.mousePos)) TaurusBaseWidget.mousePressEvent(self, event)
def __init__(self, parent=None, designMode=False, toolbar=True, **kwargs): '''see :class:`guiqwt.plot.ImageDialog` for other valid initialization parameters''' ImageDialog.__init__(self, parent=parent, toolbar=toolbar, **kwargs) TaurusBaseWidget.__init__(self, 'TaurusImageDialog') self.setWindowFlags(Qt.Qt.Widget) self.imgItem = None from taurus.qt.qtgui.extra_guiqwt.tools import TaurusModelChooserTool self.add_tool(TaurusModelChooserTool, singleModel=True) self.setModifiableByUser(True) self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
def detach(self): """Detaches the widget from the model""" TaurusBaseWidget.detach(self) # ---------------------------------------------------------------------- # Write your own code here after detaching the widget from the model # by default disable widget when dettached self.setEnabled(False)
def setModel(self, model): '''reimplemented from :class:`TaurusBaseWidget`''' TaurusBaseWidget.setModel(self, model) self._reloadConf(force=True) #set the model of some child widgets door = self.getModelObj() if door is None: return tghost = taurus.Database().getNormalName() #@todo: get the tghost from the door model instead msname = door.macro_server.getFullName() self.ui.taurusModelTree.setModel(tghost) self.ui.sardanaElementTree.setModel(msname)
def __init__(self, parent=None, door=None, plotsButton=True): Qt.QWidget.__init__(self, parent) TaurusBaseWidget.__init__(self, 'ExpDescriptionEditor') self.loadUi() self.ui.buttonBox.setStandardButtons(Qt.QDialogButtonBox.Reset | Qt.QDialogButtonBox.Apply) newperspectivesDict = copy.deepcopy(self.ui.sardanaElementTree.KnownPerspectives) #newperspectivesDict[self.ui.sardanaElementTree.DftPerspective]['model'] = [SardanaAcquirableProxyModel, SardanaElementPlainModel] newperspectivesDict[self.ui.sardanaElementTree.DftPerspective]['model'][0] = SardanaAcquirableProxyModel self.ui.sardanaElementTree.KnownPerspectives = newperspectivesDict #assign a copy because if just a key of this class memberwas modified, all instances of this class would be affected self.ui.sardanaElementTree._setPerspective(self.ui.sardanaElementTree.DftPerspective) self._localConfig = None self._originalConfiguration = None self._dirty = False self._dirtyMntGrps = set() self.connect(self.ui.activeMntGrpCB, Qt.SIGNAL('activated (QString)'), self.changeActiveMntGrp) self.connect(self.ui.createMntGrpBT, Qt.SIGNAL('clicked ()'), self.createMntGrp) self.connect(self.ui.deleteMntGrpBT, Qt.SIGNAL('clicked ()'), self.deleteMntGrp) self.connect(self.ui.compressionCB, Qt.SIGNAL('currentIndexChanged (int)'), self.onCompressionCBChanged) self.connect(self.ui.pathLE, Qt.SIGNAL('textEdited (QString)'), self.onPathLEEdited) self.connect(self.ui.filenameLE, Qt.SIGNAL('textEdited (QString)'), self.onFilenameLEEdited) self.connect(self.ui.channelEditor.getQModel(), Qt.SIGNAL('dataChanged (QModelIndex, QModelIndex)'), self._updateButtonBox) self.connect(self.ui.channelEditor.getQModel(), Qt.SIGNAL('modelReset ()'), self._updateButtonBox) preScanList = self.ui.preScanList self.connect(preScanList, Qt.SIGNAL('dataChanged'), self.onPreScanSnapshotChanged) #TODO: For Taurus 4 compatibility if hasattr(preScanList, "dataChangedSignal"): preScanList.dataChangedSignal.connect(self.onPreScanSnapshotChanged) self.connect(self.ui.choosePathBT, Qt.SIGNAL('clicked ()'), self.onChooseScanDirButtonClicked) self.__plotManager = None icon = resource.getIcon(":/actions/view.svg") self.togglePlotsAction = Qt.QAction(icon, "Show/Hide plots", self) self.togglePlotsAction.setCheckable(True) self.togglePlotsAction.setChecked(False) self.togglePlotsAction.setEnabled(plotsButton) self.addAction(self.togglePlotsAction) self.connect(self.togglePlotsAction, Qt.SIGNAL("toggled(bool)"), self.onPlotsButtonToggled) self.ui.plotsButton.setDefaultAction(self.togglePlotsAction) if door is not None: self.setModel(door) self.connect(self.ui.buttonBox, Qt.SIGNAL("clicked(QAbstractButton *)"), self.onDialogButtonClicked) #Taurus Configuration properties and delegates self.registerConfigDelegate(self.ui.channelEditor)
def setModel(self, model): '''reimplemented from :class:`TaurusBaseWidget`''' TaurusBaseWidget.setModel(self, model) self._reloadConf(force=True) # set the model of some child widgets door = self.getModelObj() if door is None: return # @todo: get the tghost from the door model instead tghost = taurus.Authority().getNormalName() msname = door.macro_server.getFullName() self.ui.taurusModelTree.setModel(tghost) self.ui.sardanaElementTree.setModel(msname) door.experimentConfigurationChanged.connect( self._experimentConfigurationChanged)
def __init__(self, parent=None, designMode=False, toolbar=True, **kwargs): '''see :class:`guiqwt.plot.CurveDialog` for other valid initialization parameters''' CurveDialog.__init__(self, parent=parent, toolbar=toolbar, **kwargs) TaurusBaseWidget.__init__(self, 'TaurusCurveDialog') self.setWindowFlags(Qt.Qt.Widget) self._designMode = designMode self._modelNames = CaselessList() from guiqwt.styles import style_generator self.style = style_generator() self.setSupportedMimeTypes( [TAURUS_MODEL_LIST_MIME_TYPE, TAURUS_ATTR_MIME_TYPE]) from taurus.qt.qtgui.extra_guiqwt.tools import TaurusCurveChooserTool self.add_tool(TaurusCurveChooserTool) self.setModifiableByUser(self._modifiableByUser) self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
def detach(self): """Detaches the widget from the model""" TaurusBaseWidget.detach(self) #---------------------------------------------------------------------- # Write your own code here after detaching the widget from the model # # Typical code is: # self.emit(QtCore.SIGNAL('valueChangedDueToEvent(QString)'), # QtCore.QString(value_str)) # self.disconnect(self, QtCore.SIGNAL('valueChangedDueToEvent(QString)'), # self.setTextValue) # by default disable widget when dettached self.setEnabled(False)
def getQtDesignerPluginInfo(cls): """reimplemented from :class:`TaurusBaseWidget`""" ret = TaurusBaseWidget.getQtDesignerPluginInfo() ret['module'] = 'taurus.qt.qtgui.plot' ret['group'] = 'Taurus Display' ret['icon'] = 'designer:qwtplot.png' return ret
def setModel(self, m): '''reimplemented from :class:`TaurusBaseWidget`''' if isinstance(m, Qt.QAbstractItemModel): self.warning( "Deprecation warning: use setQModel() if you want to set a Qt Item Model. The setModel() method is reserved for Taurus models") return Qt.QAbstractItemView.setQModel(self, m) return TaurusBaseWidget.setModel(self, m)
def getQtDesignerPluginInfo(cls): """reimplemented from :class:`TaurusBaseWidget`""" ret = TaurusBaseWidget.getQtDesignerPluginInfo() ret['module'] = 'taurus.qt.qtgui.extra_guiqwt' ret['group'] = 'Taurus Display' ret['icon'] = 'designer:qwtplot.png' return ret
def getQtDesignerPluginInfo(cls): """reimplemented from :class:`TaurusBaseWidget`""" ret = TaurusBaseWidget.getQtDesignerPluginInfo() ret['group'] = 'Taurus Input' ret['module'] = 'taurus.qt.qtgui.input' ret['icon'] = "designer:combobox.png" return ret
def displayValue(self, v): """Reimplementation of displayValue for TaurusLabel""" if self._permanentText is None: value = TaurusBaseWidget.displayValue(self, v) else: value = self._permanentText dev = None attr = None modeltype = self.getModelType() if modeltype == TaurusElementType.Device: dev = self.getModelObj() elif modeltype == TaurusElementType.Attribute: attr = self.getModelObj() dev = attr.getParent() try: v = value.format(dev=dev, attr=attr) except Exception as e: self.warning( "Error formatting display (%r). Reverting to raw string", e) v = value return v
def setModel(self, m): """reimplemented from :class:`TaurusBaseWidget`""" if isinstance(m, Qt.QAbstractItemModel): self.warning(("Deprecation warning: use setQModel() if you" + " want to set a Qt Item Model. The setModel()" + " method is reserved for Taurus models")) return Qt.QAbstractItemView.setQModel(self, m) return TaurusBaseWidget.setModel(self, m)
def setModel(self, model): TaurusBaseWidget.setModel(self, model) # Update the table modelObj = self.getModelObj() if modelObj is None: dev_name = None self.db = None else: validator = modelObj.getNameValidator() groups = validator.getUriGroups(modelObj.getFullName()) dev_name = groups['devname'] # ----------------------------------------------------------------- # Workaround for bug-256 # (use next line instead of the other one when bug-256 is fixed) # self.db = modelObj.getParentObj() # use this instead self.db = modelObj.factory().getAuthority(groups['authority']) # ----------------------------------------------------------------- self.setTable(dev_name)
def getModelClass(self): '''see :meth:`TaurusBaseComponent.getModelClass`. Note that in the case of :class:`TaurusLauncherButton`, the class is completely dependent on the widget's class''' try: return self.widget().getModelClass() except: # return None #@TODO: Uncommenting this avoids the exception when # TaurusBaseWidget.getModelClass chokes with relative classes. But # the thing should be solved at TaurusBaseWidget.getModelClass # level return TaurusBaseWidget.getModelClass(self)
def __init__(self, parent=None, designMode=False, gui=None, extraWidgets=None): Qt.QWizard.__init__(self, parent) name = "PanelDescriptionWizard" TaurusBaseWidget.__init__(self, name) self._panelDescription = None if gui is None: gui = parent if gui is not None: self._gui = weakref.proxy(gui) ###self.setOption(self.HaveFinishButtonOnEarlyPages, True) #self.namePG = NamePage() self.widgetPG = WidgetPage(extraWidgets=extraWidgets) self.advSettingsPG = AdvSettingsPage() # self.addPage(self.namePG) self.addPage(self.widgetPG) self.addPage(self.advSettingsPG)
def __init__(self, parent=None, designMode=False, toolbar=True, stackMode='deltatime', buffersize=512, options=None, **kwargs): """see :class:`guiqwt.plot.ImageDialog` for other valid initialization parameters""" defaultOptions = dict(lock_aspect_ratio=False) if options is not None: defaultOptions.update(options) ImageDialog.__init__(self, parent=parent, toolbar=toolbar, options=defaultOptions, **kwargs) TaurusBaseWidget.__init__(self, "TaurusTrend2DDialog") self.trendItem = None self.buffersize = buffersize self._useArchiving = False self._stackMode = stackMode self.setStackMode(stackMode) self.setWindowFlags(Qt.Qt.Widget) # add some tools for toolklass in (TaurusModelChooserTool, AutoScrollTool): self.add_tool(toolklass) self.get_tool(TaurusModelChooserTool).singleModel = True self.setModifiableByUser(self._modifiableByUser) self.setContextMenuPolicy(Qt.Qt.CustomContextMenu) self.registerConfigDelegate(self.get_tool(AutoScrollTool))
def attach(self): """Attaches the widget to the model""" if self.isAttached(): return True # ---------------------------------------------------------------------- # Write your own code here before attaching widget to attribute connect # the proper signal so that the first event is correctly received by the # widget ret = TaurusBaseWidget.attach(self) # by default enable/disable widget according to attach state self.setEnabled(ret) return ret
def attach(self): """Attaches the widget to the model""" if self.isAttached(): return True #---------------------------------------------------------------------- # Write your own code here before attaching widget to attribute connect # the proper signal so that the first event is correctly received by the # widget # # Typical code is: # self.connect(self, QtCore.SIGNAL('valueChangedDueToEvent(QString)'), # self.setTextValue) ret = TaurusBaseWidget.attach(self) # by default enable/disable widget according to attach state self.setEnabled(ret) return ret
def getQtDesignerPluginInfo(cls): d = TaurusBaseWidget.getQtDesignerPluginInfo() d.update(_QT_PLUGIN_INFO) return d
def getModelMimeData(self): mimeData = TaurusBaseWidget.getModelMimeData(self) mimeData.setText(self.text()) return mimeData
def setModel(self, m): # force to build another controller self._controller = None TaurusBaseWidget.setModel(self, m) if self.modelFragmentName: self.setFgRole(self.modelFragmentName)
def setModel(self, model): TaurusBaseWidget.setModel(self, model) self.update_button()
def setModifiableByUser(self, modifiable): """reimplemented from :class:`TaurusBaseWidget`""" self.get_tool(TaurusModelChooserTool).action.setEnabled(modifiable) self.get_plot().set_items_readonly(not modifiable) TaurusBaseWidget.setModifiableByUser(self, modifiable)
def setModel(self, m): # force to build another controller self._controller = None TaurusBaseWidget.setModel(self, m)
def setModifiableByUser(self, modifiable): '''reimplemented from :class:`TaurusBaseWidget`''' from taurus.qt.qtgui.extra_guiqwt.tools import TaurusModelChooserTool self.get_tool(TaurusModelChooserTool).action.setEnabled(modifiable) self.get_plot().set_items_readonly(not modifiable) TaurusBaseWidget.setModifiableByUser(self, modifiable)
def displayValue(self, v): '''see :meth:`TaurusBaseComponent.displayValue`''' if self._text is not None: return self._text # make sure the text is not changed once set TaurusBaseWidget.displayValue(self, v)
def parentModelChanged(self, parentmodel_name): TaurusBaseWidget.parentModelChanged(self, parentmodel_name) self.__loadMacroNames()
def getQtDesignerPluginInfo(cls): ret = TaurusBaseWidget.getQtDesignerPluginInfo() ret['module'] = 'taurus.qt.qtgui.table' ret['group'] = 'Taurus Views' ret['icon'] = "designer:table.png" return ret
def setModel(self, model): if isinstance(model, Qt.QAbstractItemModel): Qt.QAbstractItemView.setModel(self, model) else: TaurusBaseWidget.setModel(self, model) self.__loadMacroNames()
def getQtDesignerPluginInfo(cls): ret = TaurusBaseWidget.getQtDesignerPluginInfo() ret['module'] = 'taurus.qt.qtgui.graphic' ret['group'] = 'Taurus Display' ret['icon'] = "designer:graphicsview.png" return ret
def setModel(self, model_name): TaurusBaseWidget.setModel(self, model_name) self._elementTree.setModel(model_name) self._is_filesystem_prepared = False self.prepare_filesystem()