On Thu, Jun 5, 2014 at 11:38 AM, OisLone <oisl...@ois.idv.tw> wrote:
> Hello ALL:
>
> Now I can  use  methods  like
>
> def FuncA ():
>       print ("AAA")
>
> def FuncB ():
>       print ("BBB")
>
> q = QPushButton ("TEST")
> q.clicked.connect (FuncA)
> q.clicked.connect (FuncB)
>
> I  can use another  way?  Like  Python List
> For example:
>
> def FuncA ():
>       print ("AAA")
>
> def FuncB ():
>       print ("BBB")
>
> q = QPushButton ("TEST")
> lis = [FuncA, FuncB]
> q.clicked.connect (lis)
>
> Because only  need to define a  variable  lis,  I  can set up multiple  
> QPushButton's  connect,  if  the  need to change,    can modify the  lis  
> only.
>

You could create a closure that calls all those functions:

def multifunc(*args):
    def _multifunc():
        for fn in args:
            fn()
    return _multifunc

And use it like this:

funcs = multifunc(FuncA, FuncB)
q.clicked.connect (funcs)


Code is untested but it should get you going.
_______________________________________________
PySide mailing list
PySide@qt-project.org
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to