本文整理汇总了Python中PySide.QtCore方法的典型用法代码示例。如果您正苦于以下问题:Python PySide.QtCore方法的具体用法?Python PySide.QtCore怎么用?Python PySide.QtCore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide
的用法示例。
在下文中一共展示了PySide.QtCore方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: qt_import
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def qt_import(shi=False, cui=False):
"""
import pyside/pyQt
Returns:
multi: QtGui, QtCore, QtWidgets, wrapInstance
"""
lookup = ["PySide2", "PySide", "PyQt4"]
preferredBinding = os.environ.get("MGEAR_PYTHON_QT_BINDING", None)
if preferredBinding is not None and preferredBinding in lookup:
lookup.remove(preferredBinding)
lookup.insert(0, preferredBinding)
for binding in lookup:
try:
return _qt_import(binding, shi, cui)
except Exception:
pass
raise _qt_import("ThisBindingSurelyDoesNotExist", False, False)
示例2: load_stylesheet_pyqt5
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def load_stylesheet_pyqt5():
"""
Load the stylesheet for use in a pyqt5 application.
:param pyside: True to load the pyside rc file, False to load the PyQt rc file
:return the stylesheet string
"""
warnings.warn(
"load_stylesheet_pyqt5() will be deprecated in version 3,"
"set QtPy environment variable to specify the Qt binding and "
"use load_stylesheet()",
PendingDeprecationWarning
)
# Smart import of the rc file
import qdarkstyle.pyqt5_style_rc
# Load the stylesheet content from resources
from PyQt5.QtCore import QFile, QTextStream
f = QFile(":qdarkstyle/style.qss")
if not f.exists():
_logger().error("Unable to load stylesheet, file not found in "
"resources")
return ""
else:
f.open(QFile.ReadOnly | QFile.Text)
ts = QTextStream(f)
stylesheet = ts.readAll()
if platform.system().lower() == 'darwin': # see issue #12 on github
mac_fix = '''
QDockWidget::title
{
background-color: #31363b;
text-align: center;
height: 12px;
}
'''
stylesheet += mac_fix
return stylesheet
示例3: _qt_import
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def _qt_import(binding, shi=False, cui=False):
QtGui = None
QtCore = None
QtWidgets = None
wrapInstance = None
if binding == "PySide2":
from PySide2 import QtGui, QtCore, QtWidgets
import shiboken2 as shiboken
from shiboken2 import wrapInstance
from pyside2uic import compileUi
elif binding == "PySide":
from PySide import QtGui, QtCore
import PySide.QtGui as QtWidgets
import shiboken
from shiboken import wrapInstance
from pysideuic import compileUi
elif binding == "PyQt4":
from PyQt4 import QtGui
from PyQt4 import QtCore
import PyQt4.QtGui as QtWidgets
from sip import wrapinstance as wrapInstance
from PyQt4.uic import compileUi
print("Warning: 'shiboken' is not supported in 'PyQt4' Qt binding")
shiboken = None
else:
raise Exception("Unsupported python Qt binding '%s'" % binding)
rv = [QtGui, QtCore, QtWidgets, wrapInstance]
if shi:
rv.append(shiboken)
if cui:
rv.append(compileUi)
return rv
示例4: _pyside2_as_qt_object
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def _pyside2_as_qt_object(widget):
from PySide2.QtCore import QObject
from PySide2.QtWidgets import QWidget
from PySide2 import QtWidgets
from shiboken2 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(QtWidgets, _class, getattr(QtWidgets, _super, QWidget))
return wrapInstance(long(ptr), qclass)
示例5: _pyside_as_qt_object
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [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)
示例6: new_load_qt
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def new_load_qt(api_options):
from PySide import QtCore, QtGui, QtSvg
return QtCore, QtGui, QtSvg, 'pyside'
示例7: application
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def application():
'''Return the current instance of the IDA Application.'''
res = PySide.QtCore.QCoreApplication
return res.instance()
示例8: _select_qt_binding
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def _select_qt_binding(binding_name=None, binding_order=None):
global QT_BINDING, QT_BINDING_VERSION
# order of default bindings can be changed here
DEFAULT_BINDING_ORDER = ['pyqt', 'pyside']
binding_order = binding_order or DEFAULT_BINDING_ORDER
# determine binding preference
if binding_name:
if binding_name not in binding_order:
raise ImportError("Qt binding '%s' is unknown" % binding_name)
binding_order = [binding_name]
required_modules = [
'QtCore',
'QtGui',
'uic',
]
optional_modules = [
'QtDeclarative',
'QtMultimedia',
'QtNetwork',
'QtOpenGL',
'QtOpenVG',
'QtScript',
'QtScriptTools'
'QtSql',
'QtSvg',
'QtWebKit',
'QtXml',
'QtXmlPatterns',
'QtUiTools',
]
# try to load preferred bindings
error_msgs = []
for binding_name in binding_order:
try:
binding_loader = getattr(sys.modules[__name__], '_load_%s' % binding_name, None)
if binding_loader:
QT_BINDING_VERSION = binding_loader(required_modules, optional_modules)
QT_BINDING = binding_name
break
else:
error_msgs.append(" Binding loader '_load_%s' not found." % binding_name)
except ImportError as e:
error_msgs.append(" ImportError for '%s': %s" % (binding_name, e))
if not QT_BINDING:
raise ImportError("Could not find Qt binding (looked for: %s):\n%s" % (', '.join(["'%s'" % b for b in binding_order]), '\n'.join(error_msgs)))
示例9: _load_pyqt
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def _load_pyqt(required_modules, optional_modules):
# set environment variable QT_API for matplotlib
os.environ['QT_API'] = 'pyqt'
# select PyQt4 API, see http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html
import sip
try:
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)
except ValueError as e:
raise RuntimeError('Could not set API version (%s): did you import PyQt4 directly?' % e)
# register required and optional PyQt4 modules
for module_name in required_modules:
_named_import('PyQt4.%s' % module_name)
for module_name in optional_modules:
_named_optional_import('PyQt4.%s' % module_name)
# set some names for compatibility with PySide
sys.modules['QtCore'].Signal = sys.modules['QtCore'].pyqtSignal
sys.modules['QtCore'].Slot = sys.modules['QtCore'].pyqtSlot
sys.modules['QtCore'].Property = sys.modules['QtCore'].pyqtProperty
# try to register PyQt4.Qwt5 module
try:
import PyQt4.Qwt5
_register_binding_module('Qwt', PyQt4.Qwt5)
except ImportError:
pass
global _loadUi
def _loadUi(uifile, baseinstance=None, custom_widgets_=None):
from PyQt4 import uic
return uic.loadUi(uifile, baseinstance=baseinstance)
# override specific function to improve compatibility between different bindings
from QtGui import QFileDialog
QFileDialog.getOpenFileName = QFileDialog.getOpenFileNameAndFilter
QFileDialog.getSaveFileName = QFileDialog.getSaveFileNameAndFilter
import PyQt4.QtCore
return PyQt4.QtCore.PYQT_VERSION_STR
示例10: load_stylesheet
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def load_stylesheet(pyside=True):
"""
Load the stylesheet. Takes care of importing the rc module.
:param pyside: True to load the pyside rc file, False to load the PyQt rc file
:return the stylesheet string
"""
warnings.warn(
"load_stylesheet() will not receive pyside parameter in version 3. "
"Set QtPy environment variable to specify the Qt binding insteady.",
FutureWarning
)
# Smart import of the rc file
if pyside:
import qdarkstyle.pyside_style_rc
else:
import qdarkstyle.pyqt_style_rc
# Load the stylesheet content from resources
if not pyside:
from PyQt4.QtCore import QFile, QTextStream
else:
from PySide.QtCore import QFile, QTextStream
f = QFile(":qdarkstyle/style.qss")
if not f.exists():
_logger().error("Unable to load stylesheet, file not found in "
"resources")
return ""
else:
f.open(QFile.ReadOnly | QFile.Text)
ts = QTextStream(f)
stylesheet = ts.readAll()
if platform.system().lower() == 'darwin': # see issue #12 on github
mac_fix = '''
QDockWidget::title
{
background-color: #31363b;
text-align: center;
height: 12px;
}
'''
stylesheet += mac_fix
return stylesheet
示例11: _select_qt_binding
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def _select_qt_binding(binding_name=None, binding_order=None):
global QT_BINDING, QT_BINDING_VERSION
# order of default bindings can be changed here
DEFAULT_BINDING_ORDER = ['pyqt', 'pyside']
binding_order = binding_order or DEFAULT_BINDING_ORDER
# determine binding preference
if binding_name:
if binding_name not in binding_order:
raise ImportError("Qt binding '%s' is unknown" % binding_name)
binding_order = [binding_name]
required_modules = [
'QtCore',
'QtGui'
]
optional_modules = [
'QtDeclarative',
'QtMultimedia',
'QtNetwork',
'QtOpenGL',
'QtOpenVG',
'QtScript',
'QtScriptTools'
'QtSql',
'QtSvg',
'QtWebKit',
'QtXml',
'QtXmlPatterns',
]
# try to load preferred bindings
error_msgs = []
for binding_name in binding_order:
try:
binding_loader = globals().get('_load_%s' % binding_name, None)
if binding_loader:
QT_BINDING_VERSION = binding_loader(
required_modules, optional_modules)
QT_BINDING = binding_name
break
else:
error_msgs.append(
" Binding loader '_load_%s' not found." % binding_name)
except ImportError as e:
error_msgs.append(
" ImportError for '%s': %s" % (binding_name, e))
if not QT_BINDING:
raise ImportError(
"Could not find Qt binding (looked for: %s):\n%s" % (
', '.join(["'%s'" % b for b in binding_order]),
'\n'.join(error_msgs))
)
示例12: _load_pyqt
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def _load_pyqt(required_modules, optional_modules):
os.environ['QT_API'] = 'pyqt'
# select PyQt4 API, see
# http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html
import sip
try:
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)
except ValueError as e:
raise RuntimeError(
'Could not set API version (%s): did you import PyQt4 '
'directly?' % e)
for module_name in required_modules:
_named_import('PyQt4.%s' % module_name)
for module_name in optional_modules:
_named_optional_import('PyQt4.%s' % module_name)
# set some names for compatibility with PySide
sys.modules['PyQt4.QtCore'].Signal = sys.modules['PyQt4.QtCore'].pyqtSignal
sys.modules['PyQt4.QtCore'].Slot = sys.modules['PyQt4.QtCore'].pyqtSlot
sys.modules['PyQt4.QtCore'].Property = sys.modules['PyQt4.QtCore'].pyqtProperty
try:
import PyQt4.Qwt5
_register_binding_module('Qwt', PyQt4.Qwt5)
except ImportError:
pass
global _loadUi
def _loadUi(uifile, baseinstance=None, custom_widgets_=None):
from PyQt4 import uic
return uic.loadUi(uifile, baseinstance=baseinstance)
# override specific function to improve compatibility between different
# bindings
from PyQt4.QtGui import QFileDialog
QFileDialog.getOpenFileName = QFileDialog.getOpenFileNameAndFilter
QFileDialog.getSaveFileName = QFileDialog.getSaveFileNameAndFilter
import PyQt4.QtCore
return PyQt4.QtCore.PYQT_VERSION_STR
示例13: checkRequirements
# 需要导入模块: import PySide [as 别名]
# 或者: from PySide import QtCore [as 别名]
def checkRequirements(cq):
#checking requirements
FreeCAD.Console.PrintMessage("FC Version \r\n")
FreeCAD.Console.PrintMessage(FreeCAD.Version())
FC_majorV=str(FreeCAD.Version()[0]).replace(',','.');FC_minorV=str(FreeCAD.Version()[1]).replace(',','.')
FreeCAD.Console.PrintMessage('FC Version '+FC_majorV+FC_minorV+'\r\n')
import PySide, sys
FreeCAD.Console.PrintMessage('QtCore Version '+PySide.QtCore.qVersion()+'\n')
FreeCAD.Console.PrintMessage('Python Version '+sys.version+'\n')
if int(float(FC_majorV)) <= 0:
if int(float(FC_minorV)) < 15:
reply = QtGui.QMessageBox.information(None,"Warning! ...","use FreeCAD version >= "+FC_majorV+"."+FC_minorV+"\r\n")
#check version
cqv=cq.__version__.split(".")
#say2(cqv)
if int(cqv[0])==0 and int(cqv[1])<3:
msg = "CadQuery Module needs to be at least 0.3.0!\r\n\r\n"
reply = QtGui.QMessageBox.information(None, "Info ...", msg)
say("cq needs to be at least 0.3.0")
raise #todo: create a suitable exception
if float(cq.__version__[:-2]) < 0.3:
msg="missing CadQuery 0.3.0 or later Module!\r\n\r\n"
msg+="https://github.com/jmwright/cadquery-freecad-module/wiki\n"
msg+="actual CQ version "+cq.__version__
reply = QtGui.QMessageBox.information(None,"Info ...",msg)
raise #todo: create a suitable exception
#do a check to test all works:
try:
open_CQ_Example(FreeCAD, FreeCADGui)
close_CQ_Example(FreeCAD, FreeCADGui)
except: # catch *all* exceptions
msg="CadQuery 030 didn't open an example file!\r\n\r\n"
reply = QtGui.QMessageBox.information(None, "Error ...", msg)
FreeCAD.Console.PrintMessage("CQ 030 doesn't open example file")
raise #re-raise exception that caused the problem
return 0
###################################################################
# runGeometryCheck() maui/poeschlr
# Do the geometry check.
#
###################################################################