本文整理汇总了Python中qtpy.PYQT5属性的典型用法代码示例。如果您正苦于以下问题:Python qtpy.PYQT5属性的具体用法?Python qtpy.PYQT5怎么用?Python qtpy.PYQT5使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类qtpy
的用法示例。
在下文中一共展示了qtpy.PYQT5属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_qt511_exception
# 需要导入模块: import qtpy [as 别名]
# 或者: from qtpy import PYQT5 [as 别名]
def test_qt511_exception(mac_ver, monkeypatch):
# Remove qtpy to reimport it again
try:
del sys.modules["qtpy"]
except KeyError:
pass
# Patch stdlib to emulate a macOS system
monkeypatch.setattr("sys.platform", 'darwin')
mac_ver.return_value = ('10.10.3',)
# Patch Qt version
if PYQT5:
monkeypatch.setattr("PyQt5.QtCore.QT_VERSION_STR", '5.11.1')
else:
monkeypatch.setattr("PySide2.QtCore.__version__", '5.11.1')
# This should raise an Exception
with pytest.raises(Exception) as e:
import qtpy
assert '10.11' in str(e.value)
assert '5.11' in str(e.value)
示例2: test_qt511_no_exception
# 需要导入模块: import qtpy [as 别名]
# 或者: from qtpy import PYQT5 [as 别名]
def test_qt511_no_exception(mac_ver, monkeypatch):
# Remove qtpy to reimport it again
try:
del sys.modules["qtpy"]
except KeyError:
pass
# Patch stdlib to emulate a macOS system
monkeypatch.setattr("sys.platform", 'darwin')
mac_ver.return_value = ('10.13.2',)
# Patch Qt version
if PYQT5:
monkeypatch.setattr("PyQt5.QtCore.QT_VERSION_STR", '5.11.1')
else:
monkeypatch.setattr("PySide2.QtCore.__version__", '5.11.1')
# This should not raise an Exception
try:
import qtpy
except Exception:
pytest.fail("Error!")
示例3: wheelEvent
# 需要导入模块: import qtpy [as 别名]
# 或者: from qtpy import PYQT5 [as 别名]
def wheelEvent(self, event):
(xfo, invRes) = self.transform().inverted()
topLeft = xfo.map(self.rect().topLeft())
bottomRight = xfo.map(self.rect().bottomRight())
center = ( topLeft + bottomRight ) * 0.5
if PYQT5:
zoomFactor = 1.0 + event.angleDelta().y() * self._mouseWheelZoomRate
else:
zoomFactor = 1.0 + event.delta() * self._mouseWheelZoomRate
transform = self.transform()
# Limit zoom to 3x
if transform.m22() * zoomFactor >= 2.0:
return
self.scale(zoomFactor, zoomFactor)
# Call udpate to redraw background
self.update()
################################################
## Painting
示例4: initialize
# 需要导入模块: import qtpy [as 别名]
# 或者: from qtpy import PYQT5 [as 别名]
def initialize():
"""Initialize Qt, patching sys.exit and eventually setting up ETS"""
# This doesn't create our QApplication, just holds a reference to
# MAIN_APP, created above to show our splash screen as early as
# possible
app = qapplication()
# --- Set application icon
app.setWindowIcon(APP_ICON)
#----Monkey patching QApplication
class FakeQApplication(QApplication):
"""Spyder's fake QApplication"""
def __init__(self, args):
self = app # analysis:ignore
@staticmethod
def exec_():
"""Do nothing because the Qt mainloop is already running"""
pass
from qtpy import QtWidgets
QtWidgets.QApplication = FakeQApplication
# ----Monkey patching sys.exit
def fake_sys_exit(arg=[]):
pass
sys.exit = fake_sys_exit
# ----Monkey patching sys.excepthook to avoid crashes in PyQt 5.5+
if PYQT5:
def spy_excepthook(type_, value, tback):
sys.__excepthook__(type_, value, tback)
sys.excepthook = spy_excepthook
# Removing arguments from sys.argv as in standard Python interpreter
sys.argv = ['']
# Selecting Qt4 backend for Enthought Tool Suite (if installed)
try:
from enthought.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'
except ImportError:
pass
return app
示例5: report_issue
# 需要导入模块: import qtpy [as 别名]
# 或者: from qtpy import PYQT5 [as 别名]
def report_issue(self, traceback=""):
if PY3:
from urllib.parse import quote
else:
from urllib import quote # analysis:ignore
versions = get_versions()
# Get git revision for development version
revision = ''
if versions['revision']:
revision = versions['revision']
issue_template = """\
## Description
**What steps will reproduce the problem?**
1.
2.
3.
**What is the expected output? What do you see instead?**
**Please provide any additional information below**
%s
## Version and main components
* Spyder Version: %s %s
* Python Version: %s
* Qt Versions: %s, %s %s on %s
## Dependencies
```
%s
```
""" % (traceback,
versions['spyder'],
revision,
versions['python'],
versions['qt'],
versions['qt_api'],
versions['qt_api_ver'],
versions['system'],
dependencies.status())
url = QUrl("https://github.com/spyder-ide/spyder/issues/new")
if PYQT5:
from qtpy.QtCore import QUrlQuery
query = QUrlQuery()
query.addQueryItem("body", quote(issue_template))
url.setQuery(query)
else:
url.addEncodedQueryItem("body", quote(issue_template))
QDesktopServices.openUrl(url)
示例6: __init__
# 需要导入模块: import qtpy [as 别名]
# 或者: from qtpy import PYQT5 [as 别名]
def __init__(self, parent):
super(TableCondaPackages, self).__init__(parent)
self._parent = parent
self._searchbox = u''
self._filterbox = const.ALL
self._delegate = CustomDelegate(self)
self.row_count = None
self._advanced_mode = True
self._current_hover_row = None
self._menu = None
self._palette = {}
# To manage icon states
self._model_index_clicked = None
self.valid = False
self.column_ = None
self.current_index = None
# To prevent triggering the keyrelease after closing a dialog
# but hititng enter on it
self.pressed_here = False
self.source_model = None
self.proxy_model = None
self.setSelectionBehavior(QAbstractItemView.SelectRows)
self.setSelectionMode(QAbstractItemView.SingleSelection)
self.verticalHeader().hide()
self.setSortingEnabled(True)
self.setMouseTracking(True)
self.setAlternatingRowColors(True)
self._delegate.current_row = self.current_row
self._delegate.current_hover_row = self.current_hover_row
self._delegate.update_index = self.update
self._delegate.has_focus_or_context = self.has_focus_or_context
self.setItemDelegate(self._delegate)
self.setShowGrid(False)
self.setWordWrap(True)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.horizontalHeader().setStretchLastSection(True)
# Header setup
self._hheader = self.horizontalHeader()
if PYQT5:
self._hheader.setSectionResizeMode(self._hheader.Fixed)
else:
self._hheader.setResizeMode(self._hheader.Fixed)
# self._hheader.setStyleSheet("""QHeaderView {border: 0px;
# border-radius: 0px;};
# """)
self.sortByColumn(const.COL_NAME, Qt.AscendingOrder)
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.hide_columns()