本文整理汇总了Python中PyQt4.QtCore方法的典型用法代码示例。如果您正苦于以下问题:Python PyQt4.QtCore方法的具体用法?Python PyQt4.QtCore怎么用?Python PyQt4.QtCore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4
的用法示例。
在下文中一共展示了PyQt4.QtCore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: qt_import
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 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: setupUi
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(993, 692)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.pbLevel = QtGui.QProgressBar(self.centralwidget)
self.pbLevel.setMaximum(1000)
self.pbLevel.setProperty("value", 123)
self.pbLevel.setTextVisible(False)
self.pbLevel.setOrientation(QtCore.Qt.Vertical)
self.pbLevel.setObjectName(_fromUtf8("pbLevel"))
self.horizontalLayout.addWidget(self.pbLevel)
self.frame = QtGui.QFrame(self.centralwidget)
self.frame.setFrameShape(QtGui.QFrame.NoFrame)
self.frame.setFrameShadow(QtGui.QFrame.Plain)
self.frame.setObjectName(_fromUtf8("frame"))
self.verticalLayout = QtGui.QVBoxLayout(self.frame)
self.verticalLayout.setMargin(0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.label = QtGui.QLabel(self.frame)
self.label.setObjectName(_fromUtf8("label"))
self.verticalLayout.addWidget(self.label)
self.grFFT = PlotWidget(self.frame)
self.grFFT.setObjectName(_fromUtf8("grFFT"))
self.verticalLayout.addWidget(self.grFFT)
self.label_2 = QtGui.QLabel(self.frame)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.verticalLayout.addWidget(self.label_2)
self.grPCM = PlotWidget(self.frame)
self.grPCM.setObjectName(_fromUtf8("grPCM"))
self.verticalLayout.addWidget(self.grPCM)
self.horizontalLayout.addWidget(self.frame)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例3: new_load_qt
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def new_load_qt(api):
"""
Directly import the Qt libraries rather than autodiscovering them
"""
from PyQt4 import QtCore, QtGui, QtSvg
return QtCore, QtGui, QtSvg, 'pyqt'
示例4: load_stylesheet_pyqt5
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 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
示例5: _qt_import
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 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
示例6: PyQt4_version
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def PyQt4_version():
# FIXME, pyqt5 is also ok
from PyQt4 import QtCore
return module_stdinfo_dict(QtCore, 'PYQT_VERSION_STR')
示例7: eventFilter
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.FileOpen:
if len(self.windows) >= 1:
self.windows[0].set_url(event.url().toEncoded())
return True
return False
示例8: keyPressEvent
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def keyPressEvent(self, e):
if e.key() == QtCore.Qt.Key_Return:
apply(self.func,())
示例9: connect_slots
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def connect_slots(self, sender):
self.connect(sender, QtCore.SIGNAL('timersignal'), self.timer_actions)
self.previous_payto_e=''
示例10: change_currency_dialog
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def change_currency_dialog(self):
import operator
d = QDialog(self)
d.setWindowTitle(_('Change Currency'))
main_layout = QVBoxLayout()
change_info = QLabel( _("Note that you will need to enter your password the first time you use a new currency.\n") )
change_info.setWordWrap(True)
main_layout.addWidget(change_info)
key_info = QLabel( _("PoW: Whether this wallet verifies proof-of-work.\nServers: Number of default servers to get data from.") )
key_info.setWordWrap(True)
main_layout.addWidget(key_info)
chains_view = QTreeWidget()
chains_view.setColumnCount(4)
chains_view.setHeaderLabels([ _('Code'), _('Currency'), _('PoW'), _('Servers') ])
chains_view.setColumnWidth(0, 75)
chains_view.setColumnWidth(1, 125)
chains_view.setColumnWidth(2, 60)
chains_view.setColumnWidth(3, 50)
chains_view.setMinimumWidth(325)
chains = chainkey.chainparams._known_chains
# Yes or No
y_or_n = lambda x: 'Yes' if x==True else 'No'
for ch in sorted(chains, key=operator.attrgetter('code')):
server_trust = chainkey.chainparams.get_server_trust(ch.code)
uses_pow = server_trust['pow']
num_servers = server_trust['servers']
item = QTreeWidgetItem([ch.code, ch.coin_name, y_or_n(uses_pow), str(num_servers)])
chains_view.addTopLevelItem(item)
chains_view.setCurrentItem(chains_view.topLevelItem(0))
main_layout.addWidget(chains_view)
main_layout.addLayout(ok_cancel_buttons(d))
d.setLayout(main_layout)
if not d.exec_(): return
chaincode = str(chains_view.currentItem().text(0))
self.emit(QtCore.SIGNAL('change_currency'), chaincode)
示例11: _pyside2_as_qt_object
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 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)
示例12: _pyside_as_qt_object
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 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)
示例13: __init__
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def __init__(self, *args, **kwargs):
super(QComboBox, self).__init__(*args, **kwargs)
# self.scrollWidget=scrollWidget
self.setFocusPolicy(QtCore.Qt.StrongFocus)
示例14: test_matplotlib_qt_backend
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtCore [as 别名]
def test_matplotlib_qt_backend():
print ("testing matplotlib qt backend ...")
try:
# Matplot changed its file structure several times in history, so we
# must test all
try:
from matplotlib.backends.qt_compat import QtCore
except:
try:
from matplotlib.backends.qt4_compat import QtCore
except:
from matplotlib.backends.qt import QtCore
from PyQt4 import QtCore as QtCore4
if QtCore is QtCore4:
print ("... test passed")
return True
else:
using = QtCore.__name__.split('.')[0]
expect = QtCore4.__name__.split('.')[0]
print ("... Qt test FAILURE\n" +
" Matplotlib is using %s\n" % using +
" It must use %s\n" % expect +
" Possible reasons for that are that " +
"%s is not installed " % expect +
"or the envoriment variable QT_API is overwriting it.")
return False
except:
import traceback
print(traceback.format_exc())
print ("... If you experience this test failure, it may be an "
"expected! We would like to know why, "
"please report in 'https://github.com/nguy/artview/issues'")
return None
示例15: _select_qt_binding
# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 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)))