Пример #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")
Пример #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")
Пример #3
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
Пример #4
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
Пример #5
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 Qt module"""

from taurus.core.util.log import info
info("import of Qt from taurus.qt is deprecated. "
     "Use taurus.external.qt instead")
del info

from taurus.external.qt.Qt import *
Пример #6
0
                raise exc_class(msg)
            else:
                return False

    if QtName.startswith('PyQt'):
        req_v_str = kwargs.get('PyQt', "0")
        qt_v_str = QtCore.PYQT_VERSION_STR
    elif QtName == 'PySide':
        req_v_str = kwargs.get('PySide', "0")
        qt_v_str = QtCore.PYSIDE_VERSION_STR

    if req_v_str:
        if V(req_v_str) > V(qt_v_str):
            if exc_class:
                msg = "{0} {1} >= {2}. Installed {1} is {3}", format(
                    msg_prefix, QtName, req_v_str, qt_v_str)
                raise exc_class(msg)
            else:
                return False
    return True


if __config.QT_AUTO_INIT:
    initialize(name=__config.QT_AUTO_API,
               strict=__config.QT_AUTO_STRICT,
               logging=__config.QT_AUTO_INIT_LOG,
               resources=__config.QT_AUTO_INIT_RES,
               remove_inputhook=__config.QT_AUTO_REMOVE_INPUTHOOK)

    __log.info('Using "%s" for Qt', __QT_NAME)
Пример #7
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 QtDesigner module"""

from taurus.core.util.log import info
info("import of QtDesigner from taurus.qt is deprecated. "
     "Use taurus.external.qt instead")
del info

from taurus.external.qt.QtDesigner import *
Пример #8
0
def __import(name):
    import sys
    __import__(name)
    return sys.modules[name]


def __importQt(name):
    return __import(API_NAME + "." + name)


def getQt(name=None, strict=True):
    __log.deprecated(dep='taurus.external.qt.getQt', rel='4.0.4')
    if PYQT5:
        import PyQt5 as _qt
    elif PYQT4:
        import PyQt4 as _qt
    elif PYSIDE:
        import PySide as _qt
    else:
        raise ImportError("No suitable Qt found")
    return _qt


if getattr(__config, 'QT_AUTO_INIT_LOG', True):
    __initializeQtLogging()

if getattr(__config, 'QT_AUTO_REMOVE_INPUTHOOK', True):
    __removePyQtInputHook()

__log.info('Using "%s" for Qt', API_NAME)
Пример #9
0
    """
    import traceback
    sys.excepthook = traceback.print_exception


if getattr(__config, 'QT_AUTO_INIT_LOG', True):
    __initializeQtLogging()

if getattr(__config, 'QT_AUTO_REMOVE_INPUTHOOK', True):
    __removePyQtInputHook()

if PYQT5 and getattr(__config, 'QT_AVOID_ABORT_ON_EXCEPTION', True):
    # TODO: check if we also want to do this for PySide(2)
    __addExceptHook()

__log.info('Using %s (v%s , with Qt %s)', API_NAME, PYQT_VERSION
           or PYSIDE_VERSION, QT_VERSION)

# --------------------------------------------------------------------------
# Deprecated (in Jul17) pending to be removed later on


def getQt(name=None, strict=True):
    __log.deprecated(dep='taurus.external.qt.getQt', rel='4.0.4')
    from importlib import import_module
    return import_module(API_NAME)


def getQtName(name=None, strict=True):
    __log.deprecated(dep='taurus.external.qt.getQtName',
                     alt='taurus.external.qt.API_NAME',
                     rel='4.0.4')
Пример #10
0
                raise exc_class(msg)
            else:
                return False

    if QtName.startswith('PyQt'):
        req_v_str = kwargs.get('PyQt', "0")
        qt_v_str = QtCore.PYQT_VERSION_STR
    elif QtName == 'PySide':
        req_v_str = kwargs.get('PySide', "0")
        qt_v_str = QtCore.PYSIDE_VERSION_STR

    if req_v_str:
        if V(req_v_str) > V(qt_v_str):
            if exc_class:
                msg = "{0} {1} >= {2}. Installed {1} is {3}",format(
                    msg_prefix, QtName, req_v_str, qt_v_str)
                raise exc_class(msg)
            else:
                return False
    return True


if __config.QT_AUTO_INIT:
    initialize(name=__config.QT_AUTO_API,
               strict=__config.QT_AUTO_STRICT,
               logging=__config.QT_AUTO_INIT_LOG,
               resources=__config.QT_AUTO_INIT_RES,
               remove_inputhook=__config.QT_AUTO_REMOVE_INPUTHOOK)

    __log.info('Using "%s" for Qt', __QT_NAME)
Пример #11
0
taurus.qt.qtgui.tpg.

Note that if you really want to continue using the old Qwt5-based widgets and
avoid deprecation warnings, you can import the old API from
taurus.qt.qtgui.qwt5

Note that `PyQwt5 module <http://pyqwt.sourceforge.net/>`_
only works with Python2 and PyQt4 and is no longer supported,
so taurus is moving to other modules for plotting (pyqtgraph, silx, ...)

"""

from __future__ import absolute_import
from taurus.core.util import log as __log

__log.deprecated(dep='taurus.qt.qtgui.plot',
                 rel='4.5',
                 alt='taurus.qt.qtgui.tpg or taurus.qt.qtgui.qwt5')

try:
    from taurus.qt.qtgui.qwt5 import *
except:
    try:
        from taurus.qt.qtgui.tpg import TaurusPlot, TaurusTrend
        __log.info(
            'plot: Using taurus.qt.qtgui.tpg to provide a minimal API ' +
            'to facilitate the transition')
    except:
        __log.info('plot: Cannot import taurus.qt.qtgui.tpg to provide a ' +
                   'minimal API for transition')
Пример #12
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 QtNetwork module"""

from taurus.core.util.log import info
info("import of QtNetwork from taurus.qt is deprecated. "
     "Use taurus.external.qt instead")
del info

from taurus.external.qt.QtNetwork import *
Пример #13
0
    import traceback
    sys.excepthook = traceback.print_exception


if getattr(__config, 'QT_AUTO_INIT_LOG', True):
    __initializeQtLogging()

if getattr(__config, 'QT_AUTO_REMOVE_INPUTHOOK', True):
    __removePyQtInputHook()

if PYQT5 and getattr(__config, 'QT_AVOID_ABORT_ON_EXCEPTION', True):
    # TODO: check if we also want to do this for PySide(2)
    __addExceptHook()

__log.info('Using %s (v%s with Qt %s and Python %s)', API_NAME, PYQT_VERSION
           or PYSIDE_VERSION, QT_VERSION,
           sys.version.split()[0])

# --------------------------------------------------------------------------
# Deprecated (in Jul17) pending to be removed later on


def getQt(name=None, strict=True):
    __log.deprecated(dep='taurus.external.qt.getQt', rel='4.0.4')
    from importlib import import_module
    return import_module(API_NAME)


def getQtName(name=None, strict=True):
    __log.deprecated(dep='taurus.external.qt.getQtName',
                     alt='taurus.external.qt.API_NAME',
Пример #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 QtUiTools module"""

from taurus.core.util.log import info
info("import of QtUiTools from taurus.qt is deprecated. "
     "Use taurus.external.qt instead")
del info

from taurus.external.qt.QtUiTools import *
Пример #15
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 QtWebKit module"""

from taurus.core.util.log import info
info("import of QtWebKit from taurus.qt is deprecated. "
     "Use taurus.external.qt instead")
del info

from taurus.external.qt.QtWebKit import *