• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sip.getapi函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sip.getapi函数的典型用法代码示例。如果您正苦于以下问题:Python getapi函数的具体用法?Python getapi怎么用?Python getapi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getapi函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_sip_api_qtpy

    def test_sip_api_qtpy():
        """Preferred binding PyQt4 should have sip version 2"""

        __import__("Qt")  # Bypass linter warning
        import sip
        assert sip.getapi("QString") == 2, ("PyQt4 API version should be 2, "
                                            "instead is %s"
                                            % sip.getapi("QString"))
开发者ID:abstractfactory,项目名称:Qt.py,代码行数:8,代码来源:tests.py


示例2: _initPyQt4

	def _initPyQt4():
		"""initialize PyQt4 to be compatible with PySide"""
		import sip
		if 'PyQt4.QtCore' in sys.modules:
			# too late to configure API, let's check that it was properly parameterized...
			for api in ('QVariant', 'QString'):
				if sip.getapi(api) != 2:
					raise RuntimeError('%s API already set to V%d, but should be 2' % (api, sip.getapi(api)))
		else:
			sip.setapi("QString", 2)
			sip.setapi("QVariant", 2)
开发者ID:hmeine,项目名称:pdfdecanter,代码行数:11,代码来源:dynqt.py


示例3: import_pyqt4

def import_pyqt4(version=2):
    """
    Import PyQt4

    Parameters
    ----------
    version : 1, 2, or None
      Which QString/QVariant API to use. Set to None to use the system
      default

    ImportErrors rasied within this function are non-recoverable
    """
    # The new-style string API (version=2) automatically
    # converts QStrings to Unicode Python strings. Also, automatically unpacks
    # QVariants to their underlying objects.
    import sip

    if version is not None:
        sip.setapi('QString', version)
        sip.setapi('QVariant', version)

    from PyQt4 import QtGui, QtCore, QtSvg

    if not check_version(QtCore.PYQT_VERSION_STR, '4.7'):
        raise ImportError("IPython requires PyQt4 >= 4.7, found %s" %
                          QtCore.PYQT_VERSION_STR)

    # Alias PyQt-specific functions for PySide compatibility.
    QtCore.Signal = QtCore.pyqtSignal
    QtCore.Slot = QtCore.pyqtSlot

    # query for the API version (in case version == None)
    version = sip.getapi('QString')
    api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT
    return QtCore, QtGui, QtSvg, api
开发者ID:hrocha,项目名称:ipython,代码行数:35,代码来源:qt_loaders.py


示例4: sip_getapi

def sip_getapi(name):
    """
    Get the api version for a name.
    """
    if sip.SIP_VERSION > 0x40900:
        return sip.getapi(name)
    elif name in _API_NAMES:
        return 1
    else:
        raise ValueError("unknown API {0!r}".format(name))
开发者ID:amela,项目名称:orange3,代码行数:10,代码来源:qtcompat.py


示例5: __setPyQt4API

def __setPyQt4API(element, api_version=2):
    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("QString"))
        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
开发者ID:ESRF-BCU,项目名称:qarbon,代码行数:19,代码来源:__init__.py


示例6: load_Qt4

def load_Qt4():
    from PyQt4 import QtGui, QtCore

    # Alias PyQt-specific functions for PySide compatibility.
    QtCore.Signal = QtCore.pyqtSignal
    QtCore.Slot = QtCore.pyqtSlot

    version = sip.getapi('QString')
    api = 'pyqt4' if version == 1 else 'pyqt4v2'

    return QtCore, QtGui, api
开发者ID:CamilleBo,项目名称:pyHegel,代码行数:11,代码来源:qt_wrap.py


示例7: uni

def uni(s, encoding="gbk"):
	if sip.getapi("QString") != 2:	# api=2时QString会自动变为str类型
		if isinstance(s, QtCore.QString):
			s = unicode(s)

	if isinstance(s, unicode):
		return s
	elif isinstance(s, str):
		return unicode(s, encoding)
	else:
		return unicode(s)
开发者ID:ddcatgg,项目名称:dglib,代码行数:11,代码来源:qt_utils2.py


示例8: requireCompatibleAPI

 def requireCompatibleAPI():
     """If PyQt4's API should be configured to be compatible with PySide's
     (i.e. QString and QVariant should not be explicitly exported,
     cf. documentation of sip.setapi()), call this function to check that
     the PyQt4 was properly imported.  (It will always be configured this
     way by this module, but it could have been imported before we got a
     hand on doing so.)
     """
     if 'PyQt4.QtCore' in sys.modules:
         import sip
         for api in ('QVariant', 'QString'):
             if sip.getapi(api) != 2:
                 raise RuntimeError('%s API already set to V%d, but should be 2' % (api, sip.getapi(api)))
开发者ID:christwell,项目名称:qimage2ndarray,代码行数:13,代码来源:qt_driver.py


示例9: utf8

def utf8(u, encoding="gbk"):
	'''
	string convert (gbk -> utf-8)
	'''
	if sip.getapi("QString") != 2:	# api=2时QString会自动变为str类型
		if isinstance(u, QtCore.QString):
			u = unicode(u)

	if isinstance(u, unicode):
		return u.encode("utf-8")
	elif encoding == "utf-8":
		return u
	else:
		return unicode(u, encoding).encode("utf-8")
开发者ID:ddcatgg,项目名称:dglib,代码行数:14,代码来源:qt_utils2.py


示例10: qtapi_version

def qtapi_version():
    """Return which QString API has been set, if any

    Returns
    -------
    The QString API version (1 or 2), or None if not set
    """
    try:
        import sip
    except ImportError:
        return
    try:
        return sip.getapi('QString')
    except ValueError:
        return
开发者ID:hrocha,项目名称:ipython,代码行数:15,代码来源:qt_loaders.py


示例11: run

    def run(self):
        # show the dialog
        self.dlg.show()

        text = self.dlg.ui.text
        text.append("QGIS " + QGis.QGIS_VERSION)
        text.append("SIP " + sip.SIP_VERSION_STR + " API V" + str(sip.getapi("QVariant")))
        text.append("\n")
        tests = unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestQvariant),
                                    unittest.TestLoader().loadTestsFromTestCase(TestQstring),
                                    unittest.TestLoader().loadTestsFromTestCase(TestVectorapi)])
        unittest.TextTestRunner(verbosity=2, stream=self.dlg).run(tests)

        # Run the dialog event loop
        result = self.dlg.exec_()
        # See if OK was pressed
        if result == 1:
            pass
开发者ID:pka,项目名称:qgis-apicompat-plugin,代码行数:18,代码来源:apicompattest.py


示例12: __init__

	def __init__(self):

		"""Constructor"""

		# Determine the sip api that is used, because this depends on whether
		# or not IPython is loaded
		object.__setattr__(self, u'api', sip.getapi(u'QString'))
		if self.api not in (1,2):
			raise Exception(u'config: unknown api %s' % self.api)

		# Apply OS specific override settings
		if platform.system() == u"Windows":
			for key, value in self.config_windows.iteritems():
				self.config[key] = value
		elif platform.system() == u"Darwin":
			for key, value in self.config_mac.iteritems():
				self.config[key] = value
		elif platform.system() == u"Linux":
			for key, value in self.config_linux.iteritems():
				self.config[key] = value
开发者ID:fragtalg,项目名称:OpenSesame,代码行数:20,代码来源:config.py


示例13: __init__

    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/geometry_copier"
        # initialize locale
        locale_path = ""
        if sip.getapi("QVariant") > 1:
            # new API style
            locale = QSettings().value("locale/userLocale")[0:2]
        else:
            # the old API style
            locale = QSettings().value("locale/userLocale").toString()[0:2]

        if QFileInfo(self.plugin_dir).exists():
            locale_path = self.plugin_dir + "/i18n/geometry_copier_" + locale + ".qm"

        if QFileInfo(locale_path).exists():
            self.translator = QTranslator()
            self.translator.load(locale_path)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
        self._geom_buffer = None
开发者ID:yellow-sky,项目名称:GeometryCopier,代码行数:24,代码来源:geometry_copier.py


示例14: isSIPv2

def isSIPv2():
    return sip.getapi("QVariant") > 1
开发者ID:pgRouting,项目名称:pgRoutingLayer,代码行数:2,代码来源:pgRoutingLayer_utils.py


示例15: Exception

but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OpenSesame.  If not, see <http://www.gnu.org/licenses/>.
"""

from PyQt4 import QtCore
import libopensesame.misc
from libopensesame import debug

# Determine the sip api that is used, because this depends on whether or not
# IPython is loaded
import sip
api = sip.getapi('QString')
if api not in (1,2):
	raise Exception('config: unknown api %s' % api)

config = {
	"cfg_ver" : 0,
	"_initial_window_state" : QtCore.QByteArray(),
	"auto_update_check" : True,
	"auto_response" : False,
	"autosave_interval" : 10 * 60 * 1000,
	"autosave_max_age" : 7,
	"default_logfile_folder" : libopensesame.misc.home_folder(),
	"disabled_plugins" : "",
	"immediate_rename" : False,
	"onetabmode" : False,
	"overview_info" : False,
开发者ID:esdalmaijer,项目名称:OpenSesame,代码行数:31,代码来源:config.py


示例16: config

>>> config.set_config('my_setting', 'my_value')
>>> print config.get_config('my_setting')

NEW STYLE
=========
>>> from libqtopensesame.misc.config import cfg
>>> cfg.my_setting = 'my_value' # set
>>> print cfg.my_setting # get
"""

from PyQt4 import QtCore
import libopensesame.misc
from libopensesame import debug, exceptions
import platform
import sip
if sip.getapi(u'QString') == 2:
	QtCore.QStringList = list

class config(object):

	config = {
		u"cfg_ver" : 0,
		u"_initial_window_geometry" : QtCore.QByteArray(),
		u"_initial_window_state" : QtCore.QByteArray(),
		u"auto_update_check" : True,
		u"auto_response" : False,
		u"autosave_interval" : 10 * 60 * 1000,
		u"autosave_max_age" : 7,
		u"default_logfile_folder" : libopensesame.misc.home_folder(),
		u"default_pool_folder" : libopensesame.misc.home_folder(),
		u"disabled_plugins" : "",
开发者ID:fragtalg,项目名称:OpenSesame,代码行数:31,代码来源:config.py


示例17: tuple

#    try:
#        sip.setapi('QString', 2)
#        sip.setapi('QVariant', 2)
#    except AttributeError:
#        # PyQt < v4.6: in future version, we should warn the user 
#        # that PyQt is outdated and won't be supported by Spyder >v2.1
#        pass
    try:
        from PyQt4.QtCore import PYQT_VERSION_STR as __version__
    except ImportError:
        # Switching to PySide
        API = os.environ['QT_API'] = 'pyside'
        API_NAME = 'PySide'
    else:
        __version_info__ = tuple(__version__.split('.')+['final', 1])
        is_old_pyqt = __version__.startswith(('4.4', '4.5', '4.6', '4.7'))
        is_pyqt46 = __version__.startswith('4.6')
        import sip
        try:
            API_NAME += (" (API v%d)" % sip.getapi('QString'))
        except AttributeError:
            pass

if API == 'pyside':
    try:
        from PySide import __version__  # analysis:ignore
    except ImportError:
        raise ImportError("Spyder requires PySide or PyQt to be installed")
    else:
        is_old_pyqt = is_pyqt46 = False
开发者ID:AT-GROUP,项目名称:AT-PLANNER,代码行数:30,代码来源:__init__.py


示例18:

import sip
try:
    sip.getapi('QString')
except ValueError:
    sip.setapi('QString', 2)

import PyQt4.Qt
Qt = PyQt4.Qt
开发者ID:armonge,项目名称:EsquipulasPy,代码行数:8,代码来源:pyqtconfig.py


示例19: getQVariantValue

import sip

import qtpy


__all__ = [
    'getQVariantValue',
    'wheelAngleDelta',
]


try:
    if qtpy.PYQT5:
        QVARIANT_API = 2
    else:
        QVARIANT_API = sip.getapi('QVariant')
except ValueError:
    QVARIANT_API = 1


if QVARIANT_API == 1:
    def getQVariantValue(variant):
        return variant.toPyObject()
else:
    def getQVariantValue(variant):
        return variant

if qtpy.PYQT5:
    def wheelAngleDelta(wheelEvent):
        return wheelEvent.angleDelta().y()
else:
开发者ID:allebacco,项目名称:PyTileMap,代码行数:31,代码来源:qtsupport.py


示例20:

if __name__ != "__main__":
    print "Console Player must be started as the main script"
    sys.exit(1)

isPosix = os.name == "posix"

__debug = "-debug" in sys.argv
__devmode = "-devmode" in sys.argv
__install = "-install" in sys.argv
# launch with the -install flag to reinstall the application
__install_home = "--install=home" in sys.argv
# force install to home directort.


try:
    cur_api_ver = sip.getapi("QString")  # raises an exception when not set
except:
    cur_api_ver = 0
finally:
    # For Python 2.7, PyInstaller
    # error: http://www.pyinstaller.org/ticket/159
    # if you want to use PyInstaller, find this file:
    #   %PyInstaller%/support/rthooks/pyi_rth_qt4plugins.py
    # and add this API changing code at the top of it:
    # you do not need the api check i do above.
    # In python 3, the default is API-2
    if cur_api_ver != 2:
        API_NAMES = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"]
        API_VERSION = 2
        for name in API_NAMES:
            sip.setapi(name, API_VERSION)
开发者ID:karthik101,项目名称:console-player,代码行数:31,代码来源:ConsolePlayer.py



注:本文中的sip.getapi函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sip.isdeleted函数代码示例发布时间:2022-05-27
下一篇:
Python sip.delete函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap