python - clicked.connect() Error -


i'm working on window 10,pycharm-python 3.5.2

what trying do: if pb1(push button 1) clicked, open new window.

problem: error

 self.pb1.clicked.connect(self.soft_memory()) typeerror: argument 1 has unexpected type 'nonetype'  

since defined soft_memory(), don't see why soft_memory() nonetype. though on editor '.connect' gets highlighted , says cannot find reference 'connect' in 'function'

codes below. i've erased part of code better see. if need full code please comment.

sm.py

class sm_window(qmainwindow, qwidget):     def __init__(self, parent=none):         super().__init__()         self.initu()      def initu(self):         self.setwindowtitle("sm_window")         self.setgeometry(10, 30, 850, 850) 

ui.py

import sm  class mainwindow(qmainwindow, qwidget):      def __init__(self, parent=none):         super(mainwindow, self).__init__(parent)         self.initui()      def soft_memory(self):         self.sf = sm.sm_window()         self.sf.show()      def buttons(self):         #button sf         self.pb1 = qpushbutton("pop", self)         self.pb1.settooltip("popopopopopop")         self.pb1.move(100, 100)      def signal_to_slot(self):         self.pb1.clicked.connect(self.soft_memory())      def initui(self):         self.setwindowtitle("ui")         self.setgeometry(850, 850, 850, 850)         self.buttons()         self.signal_to_slot()         self.showmaximized()  if __name__ == "__main__":     app = qapplication(sys.argv)     ex = mainwindow()     sys.exit(app.exec()) 

the connect() method expects callable argument. when write self.soft_memory() making call method, , result of call (none, since don't explicitly return anything) being passed connect().

you want pass reference method itself.

self.pb1.clicked.connect(self.soft_memory) 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -