[PyKDE] Newbie questions ...

oliver.tomic at matforsk.no oliver.tomic at matforsk.no
Fri Feb 8 10:50:12 GMT 2002


Hi folks!

I am a PyQt newbie and I am sorry to bother you with my obviously very
simple problem. When pushing a button I can't get it done to call the
function I would like to call. I spent quite some time playing around with
self.connect(...), but I always recieve an AttributeError. I hope someone
can help me solving my "silly" problem. Underneath is some of my code and
the error I get to describe the problem.

Thanks a lot in advance for all help!!

Oliver




import sys
from qt import *

class MyWidget(QWidget):
     def __init__(self,parent=None,name=None):
          QWidget.__init__(self,parent,name)


               self.sec1x = 10; self.sec1y = 50
                         self.button1 = QPushButton("Open File",
self.GroupBox1)
               self.button1.setGeometry(self.sec1x, self.sec1y, 70, 25)

               self.connect(self.button1, SIGNAL("clicked()"),
self.slotFile)



               def slotFile(self):
                    #do something




a = QApplication(sys.argv)
w = MyWidget()
w.setGeometry(50,50,420,440)
a.setMainWidget(w)
w.show()
a.exec_loop()



Traceback (most recent call last):
  File "C:\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301, in
RunScript
    exec codeObject in __main__.__dict__
  File "C:\Python21\PyQt\GCX3.py", line 143, in ?
    w = MyWidget()
  File "C:\Python21\PyQt\GCX3.py", line 127, in __init__
    self.connect(self.button1, SIGNAL("clicked()"), self.slotFile)
AttributeError: slotFile





More information about the PyQt mailing list