def _get_value(self): '''for backwards compat with taurus < 4''' debug(repr(self)) try: return self.__fix_int(self.rvalue.magnitude) except AttributeError: return self.rvalue
def _get_w_value(self): """for backwards compat with taurus < 4""" debug(repr(self)) try: return self.__fix_int(self.wvalue.magnitude) except AttributeError: return self.wvalue
def _set_value(self, value): '''for backwards compat with taurus < 4''' debug('Setting %r to %s' % (value, self.name)) if self.rvalue is None: # we do not have a previous rvalue import numpy dtype = numpy.array(value).dtype if numpy.issubdtype(dtype, int) or numpy.issubdtype(dtype, float): msg = 'Refusing to set ambiguous value (deprecated .value API)' raise ValueError(msg) else: self.rvalue = value elif hasattr(self.rvalue, 'units'): # we do have it and is a Quantity self.rvalue = Quantity(value, units=self.rvalue.units) else: # we do have a previous value and is not a quantity self.rvalue = value
def __setPyQt4API(element, api_version=2): sip = __get_sip() try: ver = sip.getapi(element) except ValueError: ver = -1 if ver < 0: try: sip.setapi(element, api_version) __log.debug("%s API set to version %d", element, sip.getapi(element)) except ValueError: __log.warning("Error setting %s API to version %s", element, api_version, exc_info=1) return False elif ver < api_version: __log.info("%s API set to version %s (advised: version >= %s)", element, ver, api_version) return True
## ############################################################################# """This module contains all taurus tango attribute configuration""" __all__ = ["TangoFactory"] __docformat__ = "restructuredtext" try: import PyTango except ImportError: # note that if PyTango is not installed the factory will not be available from taurus.core.util.log import debug msg = 'cannot import PyTango module. ' + \ 'Taurus will not support the "tango" scheme' debug(msg) raise from taurus.core.taurusbasetypes import TaurusElementType from taurus.core.taurusfactory import TaurusFactory from taurus.core.taurusbasetypes import OperationMode from taurus.core.taurusexception import TaurusException, DoubleRegistration from taurus.core.tauruspollingtimer import TaurusPollingTimer from taurus.core.util.log import Logger, tep14_deprecation from taurus.core.util.singleton import Singleton from taurus.core.util.containers import CaselessWeakValueDict, CaselessDict from .tangodatabase import TangoAuthority from .tangoattribute import TangoAttribute from .tangodevice import TangoDevice
# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. ## # Taurus is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. ## # You should have received a copy of the GNU Lesser General Public License # along with Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################# """ guiqwt widgets plugins for Qt Designer """ try: from guiqwt.qtdesigner import create_qtdesigner_plugin PlotPlugin = create_qtdesigner_plugin("guiqwt", "guiqwt.plot", "CurveWidget", icon="curve.png") ImagePlotPlugin = create_qtdesigner_plugin("guiqwt", "guiqwt.plot", "ImageWidget", icon="image.png") except ImportError: from taurus.core.util.log import debug debug("failed to load guiqwt designer plugin")
############################################################################# """This module provides the `TangoFactory` object""" __all__ = ["TangoFactory"] __docformat__ = "restructuredtext" try: import PyTango except ImportError: # note that if PyTango is not installed the factory will not be available from taurus.core.util.log import debug msg = 'cannot import PyTango module. ' + \ 'Taurus will not support the "tango" scheme' debug(msg) raise from taurus.core.taurusbasetypes import TaurusElementType from taurus.core.taurusfactory import TaurusFactory from taurus.core.taurusbasetypes import OperationMode from taurus.core.taurusexception import TaurusException, DoubleRegistration from taurus.core.util.log import Logger, taurus4_deprecation from taurus.core.util.singleton import Singleton from taurus.core.util.containers import CaselessWeakValueDict, CaselessDict from .tangodatabase import TangoAuthority from .tangoattribute import TangoAttribute from .tangodevice import TangoDevice _Authority = TangoAuthority
# Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain ## # Taurus is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. ## # Taurus is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. ## # You should have received a copy of the GNU Lesser General Public License # along with Taurus. If not, see <http://www.gnu.org/licenses/>. ## ############################################################################# """This package contains a collection of taurus Qt gauge widgets""" __docformat__ = 'restructuredtext' try: from .taurusgauge import * except: from taurus.core.util.log import debug debug("Gauge widgets could not be initialized") from taurus.qt.qtgui.display import create_taurus_fallback as __create TaurusLinearGauge = __create("TaurusLinearGauge") TaurusCircularGauge = __create("TaurusCircularGauge") from .qmeter import *
def update_result(result): result_label.setText(str(result)) def toggle_progress(showProgress): visible = show_progress.isChecked() mb.toggleProgress(visible) # Toggle progressbar Qt.QObject.connect(show_progress, Qt.SIGNAL('stateChanged(int)'), toggle_progress) # Update possible macro result Qt.QObject.connect(mb, Qt.SIGNAL('resultUpdated'), update_result) # Obtain a demo motor try: demo_motor_name = SarDemoEnv(door_name).getMotors()[0] except Exception, e: from taurus.core.util.log import warning, debug warning('It was unable to obtain a demo motor') debug('Details: %s' % e.message) demo_motor_name = '' # Since everything is now connected, the parameters will be updated macro_name.setText('ascan') macro_params = [demo_motor_name, '0', '1', '5', '.1'] for e, v in zip(_argEditors, macro_params): e.setText(v) w.show() sys.exit(app.exec_())
import weakref from taurus.core.taurusexception import TaurusException from taurus.core.util.singleton import Singleton from taurus.core.util.log import Logger from taurus.core.taurusbasetypes import TaurusElementType from taurus.core.taurusfactory import TaurusFactory from epicsattribute import EpicsAttribute from epicsdevice import EpicsDevice from epicsauthority import EpicsAuthority try: import epics except ImportError: from taurus.core.util.log import debug debug('cannot import epics module. ' + 'Taurus will not support the "epics" scheme') raise class EpicsFactory(Singleton, TaurusFactory, Logger): """ A Singleton class that provides Epics related objects. """ schemes = ( "ca", "epics", ) DEFAULT_DEVICE = 'ca:' DEFAULT_AUTHORITY = 'ca://' caseSensitive = False
## ############################################################################# ''' Epics module. See __init__.py for more detailed documentation ''' __all__ = ['EpicsFactory'] import weakref try: import epics except ImportError: from taurus.core.util.log import debug debug('cannot import epics module. ' + 'Taurus will not support the "epics" scheme') raise from taurus.core.taurusexception import TaurusException from taurus.core.util.singleton import Singleton from taurus.core.util.log import Logger from taurus.core.taurusbasetypes import TaurusElementType from taurus.core.taurusfactory import TaurusFactory from epicsattribute import EpicsAttribute from epicsdevice import EpicsDevice from epicsauthority import EpicsAuthority class EpicsFactory(Singleton, TaurusFactory, Logger): """
sip.setapi('QString', 2) sip.setapi('QVariant', 2) sip.setapi('QDate', 2) sip.setapi('QDateTime', 2) sip.setapi('QTextStream', 2) sip.setapi('QTime', 2) sip.setapi('QUrl', 2) from PyQt4.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore from PyQt4.QtCore import QT_VERSION_STR as QT_VERSION # analysis:ignore PYSIDE_VERSION = None PYQT5 = False PYQT4 = True API = os.environ['QT_API'] = 'pyqt' # in case the original was "pyqt4" except ImportError: __log.debug('Cannot import PyQt4. Trying with PyQt5') API = os.environ['QT_API'] = 'pyqt5' if API in PYQT5_API: try: from PyQt5.QtCore import PYQT_VERSION_STR as PYQT_VERSION from PyQt5.QtCore import QT_VERSION_STR as QT_VERSION PYSIDE_VERSION = None if sys.platform == 'darwin': macos_version = LooseVersion(platform.mac_ver()[0]) if macos_version < LooseVersion('10.10'): if LooseVersion(QT_VERSION) >= LooseVersion('5.9'): raise PythonQtError("Qt 5.9 or higher only works in " + "macOS 10.10 or higher. Your " +
def update_result(result): result_label.setText(str(result)) def toggle_progress(showProgress): visible = show_progress.isChecked() mb.toggleProgress(visible) # Toggle progressbar Qt.QObject.connect(show_progress, Qt.SIGNAL('stateChanged(int)'), toggle_progress) # Update possible macro result Qt.QObject.connect(mb, Qt.SIGNAL('resultUpdated'), update_result) # Obtain a demo motor try: demo_motor_name = SarDemoEnv(door_name).getMotors()[0] except Exception, e: from taurus.core.util.log import warning, debug warning('It was unable to obtain a demo motor') debug('Details: %s' % e.message) demo_motor_name = '' # Since everything is now connected, the parameters will be updated macro_name.setText('ascan') macro_params = [demo_motor_name, '0', '1', '5', '.1'] for e,v in zip(_argEditors, macro_params): e.setText(v) w.show() sys.exit(app.exec_())
"macOS 10.10 or higher. Your " + "program will fail in this " + "system.") elif macos_version < LooseVersion('10.11'): if LooseVersion(QT_VERSION) >= LooseVersion('5.11'): raise PythonQtError("Qt 5.11 or higher only works in " + "macOS 10.11 or higher. Your " + "program will fail in this " + "system.") del macos_version except ImportError: if API: # if an specific API was requested, fail with import error raise ImportError('Cannot import PyQt5') # if no specific API was requested, allow trying other bindings __log.debug('Cannot import PyQt5') if not API or API in PYQT4_API: try: import sip sip.setapi('QString', 2) sip.setapi('QVariant', 2) sip.setapi('QDate', 2) sip.setapi('QDateTime', 2) sip.setapi('QTextStream', 2) sip.setapi('QTime', 2) sip.setapi('QUrl', 2) from PyQt4.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore from PyQt4.QtCore import QT_VERSION_STR as QT_VERSION # analysis:ignore