meandu229
Zubeman
IM trying to write a GUI app which works on my desktop but requirea pyqt4 core as it gives
ImportError: No module named PyQt4.QtCore
ImportError: No module named PyQt4.QtCore
from PyQt4 import uic
from Another import remote
from PyQt4 import QtGui
from PyQt4.QtCore import *
import urllib2
@pyqtSlot()
def upButton(self):
rem.send('input.up', '')
I really really cant shift this error
NameError: name 'pyqtSlot' is not defined
its erroring on the below
Code:@pyqtSlot() def upButton(self): rem.send('input.up', '')
def upButton(self)
rem.send("input.up", "")
PyQt4.QtCore.pyqtSlot(upButton)
Actually it is closer toJust to explain what's going on behind the scenes, your code above is pretty equivalent to:
Code:def upButton(self) rem.send("input.up", "") PyQt4.QtCore.pyqtSlot(upButton)
I might've simplified away a few too many details, but that's the concept behind decorators. The decorator (a function) just gets called on the method it's wrapping.
def upButton(self):
rem.send("input.up", "")
upButton = PyQt4.QtCore.pyqtSlot(upButton)
def upButton(self): rem.send("input.up", "")
# is roughly equivalent to:
upButton = lambda self: rem.send("input.up", "")
@pyqtSlot
def upButton(self): rem.send("input.up", "")
# can be read as:
upButton = pyqtSlot(lambda self: rem.send("input.up", ""))
upButton = pyqtSlot(
(lambda function: (setattr(function, "func_name", "upButton"), function)[-1])(
lambda self: rem.send("input.up", "")))