Bases: taurus.core.tauruslistener.TaurusListener, taurus.qt.qtcore.configuration.configuration.BaseConfigurableClass
A generic Taurus component.
Note
Any class which inherits from TaurusBaseComponent is expected to also inherit from QObject (or from a QObject derived class) If this is not fullfilled, at least the class should reimplement the getSignaller() method to return a QObject to be used for emitting and connecting signals.
Applies operations without caring about danger messages. Use TaurusBaseWidget.safeApplyOperation() if you want to warn the user before applying
Parameters: | ops (:class:~`sequence` <:class:~`taurus.core.taurusoperation.TaurusOperation`> or :class:~`None`) – list of operations to apply. If None is given (default) the component fetches the pending operations |
---|
Handle the popup menu event
Parameters: | event – the popup menu event |
---|
Reimplements the Qt.QObject deleteLater method to ensure that the this object stops listening its model.
Returns a string representation of the given value
Parameters: | v (:class:~`object`) – the value to be translated to string |
---|---|
Return type: | :class:~`str` |
Returns: | a string representing the given value |
The basic implementation of the event handling chain is as follows:
- eventReceived just calls fireEvent() which emits a “taurusEvent” PyQt signal that is connected (by preAttach()) to the filterEvent() method.
- After filtering, handleEvent() is invoked with the resulting filtered event
Note
in the earlier steps of the chain (i.e., in eventReceived()/fireEvent()), the code is executed in a Python thread, while from eventFilter ahead, the code is executed in a Qt thread. When writing widgets, one should normally work on the Qt thread (i.e. reimplementing handleEvent())
Parameters: |
|
---|
The event is processed by each and all filters in strict order unless one of them returns None (in which case the event is discarded)
Parameters: |
|
---|
Do a “best effort” to determine which model type corresponds to the given model name.
Return type: | :class:~`class TaurusModel` or :class:~`None` |
---|---|
Returns: | The class object corresponding to the type of Taurus model this widget handles or None if no valid class is found. |
Emits a “taurusEvent” signal. It is unlikely that you may need to reimplement this method in subclasses. Consider reimplementing eventReceived() or handleEvent() instead depending on whether you need to execute code in the python or Qt threads, respectively
Parameters: |
|
---|
Returns the current apply danger message or None if the apply operation is safe
Return type: | :class:~`str` or :class:~`None` |
---|---|
Returns: | the apply danger message |
Returns a string representation of the model value associated with this component.
Parameters: | cache (:class:~`bool`) – if set to True (default) use the cache value. If set to False will force a connection to the server. |
---|---|
Return type: | :class:~`str` |
Returns: | a string representation of the model value. |
Returns the list of event filters for this widget
Return type: | :class:~`sequence` <:class:~`callable`> |
---|---|
Returns: | the event filters |
Returns if apply dangerous operations is forced
Return type: | :class:~`bool` |
---|---|
Returns: | wheter or not apply dangerous operations is forced |
Returns a string with contents to be displayed in a tooltip.
Parameters: | cache (:class:~`bool`) – if set to True (default) use the cache value. If set to False will force a connection to the server. |
---|---|
Return type: | :class:~`str` |
Returns: | a tooltip |
Returns the model name for this component.
Return type: | :class:~`str` |
---|---|
Returns: | the model name. |
Return the class object for the widget. Default behavior is to do a ‘best effort’ to determine which model type corresponds to the current model name. Overwrite as necessary.
Return type: | :class:~`class TaurusModel` or :class:~`None` |
---|---|
Returns: | The class object corresponding to the type of Taurus model this widget handles or None if no valid class is found. |
Returns the current model name.
Return type: | :class:~`str` |
---|---|
Returns: | the model name |
Returns the taurus model obj associated with this component or None if no taurus model is associated.
Return type: | :class:~`taurus.core.taurusmodel.TaurusModel` or :class:~`None` |
---|---|
Returns: | the taurus model object |
Returns the taurus model type associated with this component or taurus.core.taurusbasetypes.TaurusElementType.Unknown if no taurus model is associated.
Return type: | :class:~`taurus.core.taurusbasetypes.TaurusElementType` |
---|---|
Returns: | the taurus model type |
Returns the tango obj value associated with this component or None if no taurus model is associated.
Parameters: | cache (:class:~`bool`) – if set to True (default) use the cache value. If set to False will force a connection to the server. |
---|---|
Return type: | :class:~`PyTango.DeviceAttribute` |
Returns: | the tango value object. |
Returns the current string representation when no valid model or model value exists.
Return type: | :class:~`str` |
---|---|
Returns: | a string representation for an invalid value |
Returns the parent model name or an empty string if the component has no parent
Return type: | :class:~`str` |
---|---|
Returns: | the parent model name |
Returns the parent model object or None if the component has no parent or if the parent’s model is None
Return type: | :class:~`taurus.core.taurusmodel.TaurusModel` or :class:~`None` |
---|---|
Returns: | the parent taurus model object |
Returns a parent Taurus component or None if no parent taurus.qt.qtgui.base.TaurusBaseComponent is found.
Raise: | RuntimeError |
---|
Returns the sequence of pending operations
Return type: | :class:~`sequence` <:class:~`taurus.core.taurusoperation.TaurusOperation`> |
---|---|
Returns: | a list of pending operations |
Returns if showing the quality as a background color
Return type: | :class:~`bool` |
---|---|
Returns: | True if showing the quality or False otherwise |
Returns if showing the display value
Return type: | :class:~`bool` |
---|---|
Returns: | True if showing the display value or False otherwise |
Reimplement this method if your derived class does not inherit from QObject. The return value should be a permanent object capable of emitting Qt signals. See TaurusImageItem as an example
Returns the the taurus factory singleton for the given scheme. This is just a helper method. It is the equivalent of doing:
import taurus
factory = taurus.Factory(scheme)
Parameters: | scheme (:class:~`str` or :class:~`None`) – the scheme. None defaults to ‘tango’. |
---|---|
Return type: | :class:~`taurus.core.taurusfactory.TaurusFactory` |
Returns: | the TaurusFactory |
Returns the the taurus manager singleton. This is just a helper method. It is the equivalent of doing:
import taurus
manager = taurus.Manager()
Return type: | :class:~`taurus.core.taurusmanager.TaurusManager` |
---|---|
Returns: | the TaurusManager |
Returns an xml string representing the current taurus popup menu
Return type: | :class:~`str` |
---|---|
Returns: | an xml string representing the current taurus popup menu |
Returns whether this component is using the parent model
Return type: | :class:~`bool` |
---|---|
Returns: | True if using parent model or False otherwise |
Event handling. Default implementation does nothing. Reimplement as necessary
Parameters: |
|
---|
Returns if the component has pending operations
Return type: | :class:~`bool` |
---|---|
Returns: | True if there are pending operations or False otherwise |
insert a filter in a given position
Parameters: |
|
---|
See also: setEventFilters
Determines if this component is attached to the taurus model.
Return type: | :class:~`bool` |
---|---|
Returns: | True if the component is attached or False otherwise. |
Tells if this widget’s operations are protected against exceptions
Return type: | :class:~`bool` |
---|---|
Returns: | True if operations are protected against exceptions or False otherwise |
Tells if this component value can be changed by the user. Default implementation will return True if and only if:
- this component is attached to a valid taurus model and
- the taurus model is writable and
- this component is not read-only
Return type: | :class:~`bool` |
---|---|
Returns: | True if this component value can be changed by the user or False otherwise |
Returns if the apply operation for this component is dangerous
Return type: | :class:~`bool` |
---|---|
Returns: | wheter or not the apply operation for this component is dangerous |
whether the user can change the contents of the widget
Return type: | :class:~`bool` |
---|---|
Returns: | True if the user is allowed to modify the look&feel |
Return the current pause state
Return type: | :class:~`bool` |
---|---|
Returns: | wheater or not the widget is paused |
Determines if this component is read-only or not in the sense that the user can interact with it. Default implementation returns True.
Override when necessary.
Return type: | :class:~`bool` |
---|---|
Returns: | whether or not this component is read-only |
Called inside self.attach() after actual attach is performed. Default implementation does not do anything.
Override when necessary.
Called inside self.detach() after actual deattach is performed. Default implementation does not do anything.
Override when necessary.
Called inside self.attach() before actual attach is performed. Default implementation just emits a signal.
Override when necessary.
Called inside self.detach() before actual deattach is performed. Default implementation just disconnects a signal.
Override when necessary.
Resets protecting operations
Clears the danger message. After this method is executed the apply operation for this component will be considered safe.
Clears forcing apply dangerous operations
Sets the model name to the empty string
Equivalent to setModifiableByUser(self.__class__._modifiableByUser)
Clears the list of pending operations
Resets the show quality to self.__class__._showQuality
Resets the showing of the display value to True
Resets the taurus popup menu to empty
Resets the usage of parent model to False
Sets/unsets this widget’s operations are protected against exceptions
Parameters: | protect (bool) – wheater or not to protect widget operations |
---|
Sets the danger message when applying an operation. If dangerMessage is None, the apply operation is considered safe
Parameters: | dangerMessage (:class:~`str` or :class:~`None`) – the danger message. If None is given (default) the apply operation is considered safe |
---|
sets the taurus event filters list. The filters are run in order, using each output to feed the next filter. A filter must be a function that accepts 3 arguments (evt_src, evt_type, evt_value) If the event is to be ignored, the filter must return None. If the event is not to be ignored, filter must return a (evt_src, evt_type, evt_value) tuple which may (or not) differ from the input.
For a library of common filters, see taurus/core/util/eventfilters.py
Parameters: | filters (:class:~`sequence`) – a sequence of filters |
---|
Note: If you are setting a filter that applies a transformation on the parameters, you may want to generate a fake event to force the last value to be filtered as well. This can be done as in this example:
TaurusBaseComponent.fireEvent( TaurusBaseComponent.getModelObj(),
taurus.core.taurusbasetypes.TaurusEventType.Periodic,
TaurusBaseComponent.getModelObj().getValueObj())
See also: insertEventFilter
Forces/clears the dangerous operations
Parameters: | yesno (:class:~`bool`) – force or not the dangerous operations |
---|
Sets/unsets the model name for this component
Parameters: | model (:class:~`str`) – the new model name |
---|
Sets the component taurus model. Setting the check argument to True (default) will check if the current model is equal to the given argument. If so then nothing is done. This should be the standard way to call this method since it will avoid recursion.
Parameters: |
|
---|
Sets whether the model-related properties should be stored for this widget when creating the config dict with createConfig() (and restored when calling applyConfig()). By default this is not enabled. The following properties are affected by this: - “model”
Parameters: | yesno (:class:~`bool`) – If True, the model-related properties will be registered as config properties. If False, they will be unregistered. |
---|
See also
registerConfigProperty(), createConfig(), applyConfig()
This method will detach from the previous taurus model (if any), it will set the new model to the given modelName and it will attach this component to the new taurus model.
Parameters: |
|
---|
sets whether the user is allowed to modify the look&feel
Parameters: | modifiable (:class:~`bool`) – |
---|
Sets the new string representation when no model or no model value exists.
Parameters: | v (:class:~`str`) – the string representation for an invalid value |
---|
Toggles the pause mode.
Parameters: | paused (:class:~`bool`) – whether or not to pause (default = True) |
---|
Sets/unsets the show quality property
Parameters: | showQuality (:class:~`bool`) – whether or not to show the quality |
---|
Sets/unsets showing the display value of the model
Parameters: | showText (:class:~`bool`) – whether or not to show the display value |
---|
Sets/unsets the taurus popup menu
Parameters: | menuData (:class:~`str`) – an xml representing the popup menu |
---|
Sets/unsets using the parent model
Parameters: | yesno (:class:~`bool`) – whether or not to use parent model |
---|
Converts a python dict to a tooltip string.
Parameters: | toolTipObj (:class:~`dict`) – a python object |
---|---|
Return type: | :class:~`str` |
Returns: | a tooltip |
Method called when the component detects an event that triggers a change in the style. Default implementation doesn’t do anything. Overwrite when necessary