Qt.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:SiShelf 作者: mochio326 项目源码 文件源码
def _pyqt4():
    import sip
    try:
        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)
    except AttributeError as e:
        raise ImportError(str(e))
        # PyQt4 < v4.6
    except ValueError as e:
        # API version already set to v1
        raise ImportError(str(e))

    from PyQt4 import (
        QtGui,
        QtCore,
        QtNetwork,
        QtXml,
        QtHelp,
        uic
    )

    QtWidgets = QtGui

    Qt.__binding__ = "PyQt4"
    Qt.__qt_version__ = QtCore.QT_VERSION_STR
    Qt.__binding_version__ = QtCore.PYQT_VERSION_STR
    QtCompat.load_ui = lambda fname: uic.loadUi(fname)
    QtCompat.setSectionResizeMode = QtGui.QHeaderView.setResizeMode

    # PySide2 differs from Qt4 in that Qt4 has one extra argument
    # which is always `None`. The lambda arguments represents the PySide2
    # interface, whereas the arguments passed to `.translate` represent
    # those expected of a Qt4 binding.
    QtCompat.translate = (
        lambda context, sourceText, disambiguation, n:
        QtCore.QCoreApplication.translate(context,
                                          sourceText,
                                          disambiguation,
                                          QtCore.QCoreApplication.CodecForTr,
                                          n))

    return QtCore, QtGui, QtWidgets, QtNetwork, QtXml, QtHelp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号