我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用PySide.QtCore.Slot()。
def import_pyqt5(): """ Import PyQt5 ImportErrors rasied within this function are non-recoverable """ import sip from PyQt5 import QtCore, QtSvg, QtWidgets, QtGui # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot # Join QtGui and QtWidgets for Qt4 compatibility. QtGuiCompat = types.ModuleType('QtGuiCompat') QtGuiCompat.__dict__.update(QtGui.__dict__) QtGuiCompat.__dict__.update(QtWidgets.__dict__) api = QT_API_PYQT5 return QtCore, QtGuiCompat, QtSvg, api
def toggleShowBoxes( self ): print( "Trying box overlay" ) self.viewCanvas.plotObj.plotDict['boxMask'] = None if self.tbShowBoxes.isChecked(): # Load from the zorroObj try: print( "figBoxMask: " + str(self.viewCanvas.zorroObj.files['figBoxMask']) ) except: pass if 'figBoxMask' in self.viewCanvas.zorroObj.files: self.viewCanvas.plotObj.plotDict['boxMask'] = matplotlib.image.imread( self.viewCanvas.zorroObj.files['figBoxMask'] ) self.viewCanvas.updatePlotFunc( self.comboView.currentText() ) # Decorators to stop multiple events (doesn't work damnit, everything is float) # @QtCore.Slot(float) # @QtCore.Slot(str)
def import_pyqt4(version=2): """ Import PyQt4 Parameters ---------- version : 1, 2, or None Which QString/QVariant API to use. Set to None to use the system default ImportErrors rasied within this function are non-recoverable """ # The new-style string API (version=2) automatically # converts QStrings to Unicode Python strings. Also, automatically unpacks # QVariants to their underlying objects. import sip if version is not None: sip.setapi('QString', version) sip.setapi('QVariant', version) from PyQt4 import QtGui, QtCore, QtSvg if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): raise ImportError("IPython requires PyQt4 >= 4.7, found %s" % QtCore.PYQT_VERSION_STR) # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot # query for the API version (in case version == None) version = sip.getapi('QString') api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT return QtCore, QtGui, QtSvg, api
def showMessage(self, msg, msg2, msg3): """Open a message box and display the specified message.""" self.sendTimeStepFromSankey.emit(int(msg),int(msg2),int(msg3)) @QtCore.Slot(str,str,str,str) def brushTimesteps(self, Start, End, StartSliceNoGlobal, EndSliceNoGlobal): print Start, End, StartSliceNoGlobal, EndSliceNoGlobal
def readFile(): #Should be swapped with a read of a template class JavaScriptObjectToSend(QtCore.QObject): """Simple class with one slot and one read-only property.""" @QtCore.Slot(str) def showMessage(self, msg): """Open a message box and display the specified message.""" QtGui.QMessageBox.information(None, "Info", msg) def _pyVersion(self): """Return the Python version.""" return sys.version """Python interpreter version property.""" pyVersion = Property(str, fget=_pyVersion) class jsonObject(QObject): def __init__(self,startval=42): QObject.__init__(self) self.ppval="source" self.pp = Property(str,self.readPP,self.setPP) @QtCore.Slot(str) def readPP(self,msg): return msg,self.ppval @QtCore.Slot(str) def setPP(self,val): self.ppval = val obj = jsonObject() basepath = os.path.dirname(os.path.abspath(__file__)) basepath = str(basepath)+'/' win = QtWebKit.QWebView() win.setWindowTitle('D3d visualization') layout = QtGui.QVBoxLayout() win.setLayout(layout) myObj = JavaScriptObjectToSend() view = QtWebKit.QWebView() view.settings().setAttribute(QtWebKit.QWebSettings.LocalContentCanAccessRemoteUrls, True) view.page().mainFrame().addToJavaScriptWindowObject("pyObj", myObj) view.page().mainFrame().addToJavaScriptWindowObject("jsonObj", obj) view.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True) view.settings().setAttribute(QtWebKit.QWebSettings.WebAttribute.DeveloperExtrasEnabled, True) view.settings().setAttribute(QtWebKit.QWebSettings.PrivateBrowsingEnabled, True) view.setHtml(html, baseUrl=QtCore.QUrl().fromLocalFile(basepath)) return view