本文整理汇总了Python中PySide2.QtGui方法的典型用法代码示例。如果您正苦于以下问题:Python PySide2.QtGui方法的具体用法?Python PySide2.QtGui怎么用?Python PySide2.QtGui使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide2
的用法示例。
在下文中一共展示了PySide2.QtGui方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_pyqt5
# 需要导入模块: import PySide2 [as 别名]
# 或者: from PySide2 import QtGui [as 别名]
def _setup_pyqt5():
global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName
if QT_API == QT_API_PYQT5:
from PyQt5 import QtCore, QtGui, QtWidgets
__version__ = QtCore.PYQT_VERSION_STR
QtCore.Signal = QtCore.pyqtSignal
QtCore.Slot = QtCore.pyqtSlot
QtCore.Property = QtCore.pyqtProperty
elif QT_API == QT_API_PYSIDE2:
from PySide2 import QtCore, QtGui, QtWidgets, __version__
else:
raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
_getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
def is_pyqt5():
return True
示例2: test_membership
# 需要导入模块: import PySide2 [as 别名]
# 或者: from PySide2 import QtGui [as 别名]
def test_membership():
"""Common members of Qt.py exist in all bindings, excl exceptions"""
import Qt
common_members = Qt._common_members.copy()
if os.environ.get('VFXPLATFORM') == '2017':
# For CY2017, skip the following
common_members['QtGui'].remove('QDesktopServices')
common_members.pop('QtOpenGL', None)
common_members.pop('QtMultimedia', None)
missing = list()
for module, members in common_members.items():
missing.extend(
member for member in members
if not hasattr(getattr(Qt, module), member)
)
binding = Qt.__binding__
assert not missing, (
"Some members did not exist in {binding}\n{missing}".format(
**locals())
)
示例3: _pyside_as_qt_object
# 需要导入模块: import PySide2 [as 别名]
# 或者: from PySide2 import QtGui [as 别名]
def _pyside_as_qt_object(widget):
from PySide.QtCore import QObject
from PySide.QtGui import QWidget
from PySide import QtGui
from shiboken import wrapInstance
if hasattr(widget, '__qt_object__'):
return widget.__qt_object__
ptr = _find_widget_ptr(widget)
qobject = wrapInstance(long(ptr), QObject)
meta = qobject.metaObject()
_class = meta.className()
_super = meta.superClass().className()
qclass = getattr(QtGui, _class, getattr(QtGui, _super, QWidget))
return wrapInstance(long(ptr), qclass)
示例4: _pyqt4_as_qt_object
# 需要导入模块: import PySide2 [as 别名]
# 或者: from PySide2 import QtGui [as 别名]
def _pyqt4_as_qt_object(widget):
from sip import wrapinstance
# Seting to api level 2 to better align with PySide behavior.
sip.setapi('QDate', 2)
sip.setapi('QDateTime', 2)
sip.setapi('QString', 2)
sip.setapi('QtextStream', 2)
sip.setapi('Qtime', 2)
sip.setapi('QUrl', 2)
sip.setapi('QVariant', 2)
from PyQt4.QtGui import QWidget
if hasattr(widget, '__qt_object__'):
return widget.__qt_object__
ptr = _find_widget_ptr(widget)
return wrapinstance(long(ptr), QWidget)
示例5: test_convert_simple
# 需要导入模块: import PySide2 [as 别名]
# 或者: from PySide2 import QtGui [as 别名]
def test_convert_simple():
"""python -m Qt --convert works in general"""
before = """\
from PySide2 import QtCore, QtGui, QtWidgets
class Ui_uic(object):
def setupUi(self, uic):
self.retranslateUi(uic)
def retranslateUi(self, uic):
self.pushButton_2.setText(
QtWidgets.QApplication.translate("uic", "NOT Ok", None, -1))
""".split("\n")
after = """\
from Qt import QtCompat, QtCore, QtGui, QtWidgets
class Ui_uic(object):
def setupUi(self, uic):
self.retranslateUi(uic)
def retranslateUi(self, uic):
self.pushButton_2.setText(
QtCompat.translate("uic", "NOT Ok", None, -1))
""".split("\n")
from Qt import QtCompat
assert QtCompat._convert(before) == after, after
示例6: test_coexistence
# 需要导入模块: import PySide2 [as 别名]
# 或者: from PySide2 import QtGui [as 别名]
def test_coexistence():
"""Qt.py may be use alongside the actual binding"""
from Qt import QtCore
import PySide2.QtGui
# Qt remaps QStringListModel
assert QtCore.QStringListModel
# But does not delete the original
assert PySide2.QtGui.QStringListModel
示例7: _setup_pyqt4
# 需要导入模块: import PySide2 [as 别名]
# 或者: from PySide2 import QtGui [as 别名]
def _setup_pyqt4():
global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName
def _setup_pyqt4_internal(api):
global QtCore, QtGui, QtWidgets, \
__version__, is_pyqt5, _getSaveFileName
# List of incompatible APIs:
# http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html
_sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime",
"QUrl", "QVariant"]
try:
import sip
except ImportError:
pass
else:
for _sip_api in _sip_apis:
try:
sip.setapi(_sip_api, api)
except ValueError:
pass
from PyQt4 import QtCore, QtGui
__version__ = QtCore.PYQT_VERSION_STR
# PyQt 4.6 introduced getSaveFileNameAndFilter:
# https://riverbankcomputing.com/news/pyqt-46
if __version__ < LooseVersion("4.6"):
raise ImportError("PyQt<4.6 is not supported")
QtCore.Signal = QtCore.pyqtSignal
QtCore.Slot = QtCore.pyqtSlot
QtCore.Property = QtCore.pyqtProperty
_getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter
if QT_API == QT_API_PYQTv2:
_setup_pyqt4_internal(api=2)
elif QT_API == QT_API_PYSIDE:
from PySide import QtCore, QtGui, __version__, __version_info__
# PySide 1.0.3 fixed the following:
# https://srinikom.github.io/pyside-bz-archive/809.html
if __version_info__ < (1, 0, 3):
raise ImportError("PySide<1.0.3 is not supported")
_getSaveFileName = QtGui.QFileDialog.getSaveFileName
elif QT_API == QT_API_PYQT:
_setup_pyqt4_internal(api=1)
else:
raise ValueError("Unexpected value for the 'backend.qt4' rcparam")
QtWidgets = QtGui
def is_pyqt5():
return False
示例8: test_convert_idempotency
# 需要导入模块: import PySide2 [as 别名]
# 或者: from PySide2 import QtGui [as 别名]
def test_convert_idempotency():
"""Converting a converted file produces an identical file"""
before = """\
from PySide2 import QtCore, QtGui, QtWidgets
class Ui_uic(object):
def setupUi(self, uic):
self.retranslateUi(uic)
def retranslateUi(self, uic):
self.pushButton_2.setText(
QtWidgets.QApplication.translate("uic", "NOT Ok", None, -1))
"""
after = """\
from Qt import QtCompat, QtCore, QtGui, QtWidgets
class Ui_uic(object):
def setupUi(self, uic):
self.retranslateUi(uic)
def retranslateUi(self, uic):
self.pushButton_2.setText(
QtCompat.translate("uic", "NOT Ok", None, -1))
"""
fname = os.path.join(self.tempdir, "idempotency.py")
with open(fname, "w") as f:
f.write(before)
from Qt import QtCompat
os.chdir(self.tempdir)
QtCompat._cli(args=["--convert", "idempotency.py"])
with open(fname) as f:
assert f.read() == after
QtCompat._cli(args=["--convert", "idempotency.py"])
with open(fname) as f:
assert f.read() == after