Esempio n. 1
0
def __initializeTheme():
    """Currently not used"""
    import os
    QtGui = __importQt("QtGui")

    # Can only resources if QApplication already exists
    app = QtGui.QApplication.instance()
    if app is None:
        raise SystemError("QApplication object must exist before "
                          "initializing Qt resources")

    tango_theme_dir = __get_taurus_tango_theme_path()

    # initialize theme if necessary
    theme = __getTheme()
    has_theme = len(theme) > 0
    if not has_theme:
        __log.info("No native theme support. Using local tango-theme-icons")
        if os.path.isdir(tango_theme_dir):
            # If themes are not supported (windows, for example), taurus
            # initializes local Tango theme
            theme_search_path = QtGui.QIcon.themeSearchPaths()
            theme_search_path.append(tango_theme_dir)
            QtGui.QIcon.setThemeSearchPaths(theme_search_path)
            QtGui.QIcon.setThemeName("Tango")
        else:
            __log.warning(
                "Local tango-theme-icons not found: Theme not initialized")
Esempio n. 2
0
def __initializeTheme():
    """Currently not used"""
    import os
    QtGui = __importQt("QtGui")

    # Can only resources if QApplication already exists
    app = QtGui.QApplication.instance()
    if app is None:
        raise SystemError("QApplication object must exist before "
                          "initializing Qt resources")

    tango_theme_dir = __get_taurus_tango_theme_path()

    # initialize theme if necessary
    theme = __getTheme()
    has_theme = len(theme) > 0
    if not has_theme:
        __log.info("No native theme support. Using local tango-theme-icons")
        if os.path.isdir(tango_theme_dir):
            # If themes are not supported (windows, for example), taurus
            # initializes local Tango theme
            theme_search_path = QtGui.QIcon.themeSearchPaths()
            theme_search_path.append(tango_theme_dir)
            QtGui.QIcon.setThemeSearchPaths(theme_search_path)
            QtGui.QIcon.setThemeName("Tango")
        else:
            __log.warning("Local tango-theme-icons not found: Theme not initialized")
Esempio n. 3
0
    def __init__(self, parent=None):
        Qt.QPlainTextEdit.__init__(self, parent)
        self.setReadOnly(True)
        self.setFont(Qt.QFont("Courier", 9))
        self.stopAction = Qt.QAction("Stop scrolling", self)
        self.stopAction.setCheckable(True)
        self.stopAction.setChecked(False)
        self._isStopped = False

        from taurus.core.util.log import warning

        msg = ("DoorDebug is deprecated since version 3.0.3. "
               "Use DoorOutput 'Show debug details' feature instead.")
        warning(msg)
Esempio n. 4
0
    def get(self, cache=False):
        door = self._door
        macro_server = door.macro_server
        env = door.getEnvironment()

        ret = dict(ScanDir=env.get('ScanDir'),
                   DataCompressionRank=env.get('DataCompressionRank', 1),
                   PreScanSnapshot=env.get('PreScanSnapshot', []))
        scan_file = env.get('ScanFile')
        if scan_file is None:
            scan_file = []
        elif isinstance(scan_file, (str, unicode)):
            scan_file = [scan_file]
        ret['ScanFile'] = scan_file
        mnt_grps = macro_server.getElementsOfType("MeasurementGroup")
        mnt_grps_names = [mnt_grp.name for mnt_grp in mnt_grps.values()]
        mnt_grps_full_names = mnt_grps.keys()

        active_mnt_grp = env.get('ActiveMntGrp')
        if active_mnt_grp is None and len(mnt_grps):
            active_mnt_grp = mnt_grps_names[0]
            door.putEnvironment('ActiveMntGrp', active_mnt_grp)

        ret['ActiveMntGrp'] = active_mnt_grp
        ret['MntGrpConfigs'] = mnt_grp_configs = CaselessDict()

        if len(mnt_grps) == 0:
            return ret

        mnt_grp_grps = PyTango.Group("grp")
        # use full names cause we may be using a different Tango database
        mnt_grp_grps.add(mnt_grps_full_names)

        codec = CodecFactory().getCodec('json')
        replies = mnt_grp_grps.read_attribute("configuration")
        for mnt_grp, reply in zip(mnt_grps_names, replies):
            try:
                mnt_grp_configs[mnt_grp] = \
                    codec.decode(('json', reply.get_data().value),
                                 ensure_ascii=True)[1]
            except Exception, e:
                from taurus.core.util.log import warning
                warning('Cannot load Measurement group "%s": %s',
                        repr(mnt_grp), repr(e))
Esempio n. 5
0
    def get(self, cache=False):
        door = self._door
        macro_server = door.macro_server
        env = door.getEnvironment()

        ret = dict(ScanDir=env.get('ScanDir'),
                   DataCompressionRank=env.get('DataCompressionRank', 1),
                   PreScanSnapshot=env.get('PreScanSnapshot', []))
        scan_file = env.get('ScanFile')
        if scan_file is None:
            scan_file = []
        elif isinstance(scan_file, (str, unicode)):
            scan_file = [scan_file]
        ret['ScanFile'] = scan_file
        mnt_grps = macro_server.getElementsOfType("MeasurementGroup")
        mnt_grps_names = [mnt_grp.name for mnt_grp in mnt_grps.values()]
        mnt_grps_full_names = mnt_grps.keys()

        active_mnt_grp = env.get('ActiveMntGrp')
        if active_mnt_grp is None and len(mnt_grps):
            active_mnt_grp = mnt_grps_names[0]
            door.putEnvironment('ActiveMntGrp', active_mnt_grp)

        ret['ActiveMntGrp'] = active_mnt_grp
        ret['MntGrpConfigs'] = mnt_grp_configs = CaselessDict()

        if len(mnt_grps) == 0:
            return ret

        mnt_grp_grps = PyTango.Group("grp")
        # use full names cause we may be using a different Tango database
        mnt_grp_grps.add(mnt_grps_full_names)

        codec = CodecFactory().getCodec('json')
        replies = mnt_grp_grps.read_attribute("configuration")
        for mnt_grp, reply in zip(mnt_grps_names, replies):
            try:
                mnt_grp_configs[mnt_grp] = \
                    codec.decode(('json', reply.get_data().value),
                                 ensure_ascii=True)[1]
            except Exception, e:
                from taurus.core.util.log import warning
                warning('Cannot load Measurement group "%s": %s',
                        repr(mnt_grp), repr(e))
Esempio n. 6
0
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
Esempio n. 7
0
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
Esempio n. 8
0
def __preparePyQt4():
    import sys

    # In python 3 APIs are set to level 2 so nothing to do
    if sys.version_info[0] > 2:
        return __import("PyQt4")

    sip = __get_sip()

    # For PySide compatibility, use the new-style string API that
    # automatically converts QStrings to Unicode Python strings. Also,
    # automatically unpack QVariants to their underlying objects.
    if sip is None:
        __log.warning("Could not find sip")
    elif sip.SIP_VERSION < 0x040900:
        sip_ver = sip.SIP_VERSION_STR
        __log.warning("Using old sip %s (advised >= 4.9)", sip_ver)
    else:
        for obj in ("QDate", "QDateTime", "QString", "QTextStream", "QTime",
                    "QUrl", "QVariant"):
            __setPyQt4API(obj, 2)

    return __import("PyQt4")
Esempio n. 9
0
def __preparePyQt4():
    import sys

    # In python 3 APIs are set to level 2 so nothing to do
    if sys.version_info[0] > 2:
        return __import("PyQt4")

    sip = __get_sip()

    # For PySide compatibility, use the new-style string API that
    # automatically converts QStrings to Unicode Python strings. Also,
    # automatically unpack QVariants to their underlying objects.
    if sip is None:
        __log.warning("Could not find sip")
    elif sip.SIP_VERSION < 0x040900:
        sip_ver = sip.SIP_VERSION_STR
        __log.warning("Using old sip %s (advised >= 4.9)", sip_ver)
    else:
        for obj in ("QDate", "QDateTime", "QString", "QTextStream", "QTime",
          "QUrl", "QVariant"):
            __setPyQt4API(obj, 2)

    return __import("PyQt4")
Esempio n. 10
0
    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_())
Esempio n. 11
0
Provides widget classes and functions.
.. warning:: Only PyQt4/PySide QtGui classes compatible with PyQt5.QtWidgets
    are exposed here. Therefore, you need to treat/use this package as if it
    were the ``PyQt5.QtWidgets`` module.
"""

from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError
from taurus.core.util import log as __log

if PYQT5:
    from PyQt5.QtWidgets import *
elif PYSIDE2:
    from PySide2.QtWidgets import *
elif PYQT4:
    __log.warning('Using QtWidgets with PyQt4 is not supported and may fail ' +
                  'in many cases. Use at your own risk ' +
                  '(or use a Qt5 binding)')
    from PyQt4.QtGui import *
    QStyleOptionViewItem = QStyleOptionViewItemV4
    del QStyleOptionViewItemV4

    # These objects belong to QtGui
    try:
        # Older versions of PyQt4 do not provide these
        del (QGlyphRun, QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2,
             QMatrix3x3, QMatrix3x4, QMatrix4x2, QMatrix4x3, QMatrix4x4,
             QQuaternion, QRadialGradient, QRawFont, QRegExpValidator,
             QStaticText, QTouchEvent, QVector2D, QVector3D, QVector4D,
             qFuzzyCompare)
    except NameError:
        pass
Esempio n. 12
0
    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_())
Esempio n. 13
0
File: Qwt5.py Progetto: cmft/taurus
##
# This file is part of Taurus
##
# http://taurus-scada.org
##
# 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 module exposes Qwt5 module"""

from taurus.core.util.log import warning
warning("importing Qwt5 from taurus.qt is deprecated. Use "
        "taurus.external.qt instead")
del warning

from taurus.external.qt.Qwt5 import *
Esempio n. 14
0
#############################################################################
##
# This file is part of Taurus
##
# http://taurus-scada.org
##
# 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 module exposes Qwt5 module"""

from taurus.core.util.log import warning
warning("importing Qwt5 from taurus.qt is deprecated. Use "
        "taurus.external.qt instead")
del warning

from taurus.external.qt.Qwt5 import *