pyqt - arguments for partial function in python -


i have function defined this:

def func(self, boolval): 

and want create connection between qpushbutton() , function this:

self.button1.clicked.connect(partial(self.func, false)) 

when run this, tells me func() takes 2 arguments (3 given) knows why happened?

functools.partial works fine.

see following example:

from functools import partial pyqt4.qtgui import *  class mywindow(qwidget):     def __init__(self):         super(qwidget, self).__init__()         self.button = qpushbutton('test', parent=self)         self.button.clicked.connect(partial(self.func, false))         self.button.show()     def func(self, boolvar):         print boolvar  app = qapplication([]) win = mywindow() win.show() app.exec_() 

if still error replace func signature with:

def func(self, boolvar, checked):     print boolvar 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -