Je me remets à pyqt et j’ai un peu de mal :ane:.
Je poste ici car il y a plus de chance que se soit des linuxiens qui utilise pyqt.
Voila mon code (dsl je ne peux pas faire plus court)
from qt import *
import sys
import os
class MainWindow(QMainWindow):
def __init__(self, *args):
apply(QMainWindow.__init__, (self,) + args)
self.setCaption("TEST")
self.grid=QGrid(2, self)
self.grid.setFrameShape(QFrame.StyledPanel)
self.bn1=QPushButton("1", self.grid)
self.bn1.setDefault(1)
self.bn1.connect(self.bn1, SIGNAL("clicked()"),
SetChannel1)
self.bn2=QPushButton("2", self.grid)
self.bn2.setDefault(1)
self.bn2.connect(self.bn2, SIGNAL("clicked()"),
self.SetChannel)
self.setCentralWidget(self.grid)
def SetChannel(self,freq):
print freq
def SetChannel1():
print 1
def SetChannel2():
print 2
def main(args):
app=QApplication(args)
win=MainWindow()
win.show()
app.connect(app, SIGNAL("lastWindowClosed()")
, app
, SLOT("quit()")
)
app.exec_loop()
if __name__=="__main__":
main(sys.argv)
Ca marche mais je voudrais avoir une seule fonction SetChannel(toto): print toto
Le pb est que self.bn1.connect(self.bn1, SIGNAL(“clicked()”), SetChannel(1))
ne marche pas
et je ne sais pas comment corriger ça :pleure:.
La doc sur le passage d’argu avec les slots/signaux n’est pas claire du tout 
Qlqn m’a suivi jusque là?? Qlqn sait comment faire? 
Du code python non indenté cest pas ce qu’il y a de plus lisible 
ha oui dsl je vais essayer d’arranger ça 
from qt import *
import sys
import os
class MainWindow(QMainWindow):
def __init__(self, *args):
apply(QMainWindow.__init__, (self,) + args)
self.setCaption("TEST")
self.grid=QGrid(2, self)
self.grid.setFrameShape(QFrame.StyledPanel)
self.bn1=QPushButton("1", self.grid)
self.bn1.setDefault(1)
self.bn1.connect(self.bn1, SIGNAL("clicked()"),
SetChannel1)
self.bn2=QPushButton("2", self.grid)
self.bn2.setDefault(1)
self.bn2.connect(self.bn2, SIGNAL("clicked()"),
SetChannel2)
self.setCentralWidget(self.grid)
def SetChannel(self,freq):
print freq
def SetChannel1():
print 1
def SetChannel2():
print 2
def main(args):
app=QApplication(args)
win=MainWindow()
win.show()
app.connect(app, SIGNAL("lastWindowClosed()")
, app
, SLOT("quit()")
)
app.exec_loop()
if __name__=="__main__":
main(sys.argv)
Le code corrigé de cette manière fonctionne 
Edit : bon maintenant je regarde la fonction unique que tu veut utiliser
from qt import *
import sys
import os
class Chanel:
def __init__( self, chanelId ):
self.cid = chanelId
def setChanel( self ):
print self.cid
class MainWindow(QMainWindow):
def __init__(self, *args):
apply(QMainWindow.__init__, (self,) + args)
self.setCaption("TEST")
self.grid=QGrid(2, self)
self.grid.setFrameShape(QFrame.StyledPanel)
self.bn1=QPushButton("1", self.grid)
self.bn1.setDefault(1)
self.chanel1 = Chanel(1)
self.bn1.connect(self.bn1, SIGNAL("clicked()"), self.chanel1.setChanel)
self.bn2=QPushButton("2", self.grid)
self.bn2.setDefault(1)
self.chanel2 = Chanel( 2)
self.bn2.connect(self.bn2, SIGNAL("clicked()"), self.chanel2.setChanel)
self.setCentralWidget(self.grid)
Ca peut aller ça ??? … Pas trop à mon avis 
J’ai fait une petite bidouille qui semble marcher 
je fais une class derivé de QPushButton qui intercepte le signal clicked et emet le signal btclicked avec une variable en argument.
from qt import *
import sys
import os
class CButton(QPushButton):
def __init__(self, foo, *args):
QPushButton.__init__(self, *args)
self.foo=foo
self.connect(self, SIGNAL("clicked()"), self.dclic)
def dclic(self):
self.emit(PYSIGNAL("btclicked()"),(self, self.foo))
class MainWindow(QMainWindow):
def __init__(self, *args):
apply(QMainWindow.__init__, (self,) + args)
self.setCaption("TEST")
self.grid=QGrid(2, self)
self.grid.setFrameShape(QFrame.StyledPanel)
self.bn1=CButton("toto", "1", self.grid)
self.bn1.setDefault(1)
self.bn1.connect(self.bn1, PYSIGNAL("btclicked()"),
SetChannel)
self.bn2=CButton("titi", "2", self.grid)
self.bn2.setDefault(1)
self.bn2.connect(self.bn2, PYSIGNAL("btclicked()"),
SetChannel)
self.setCentralWidget(self.grid)
def SetChannel(self, pouet):
print pouet
def main(args):
app=QApplication(args)
win=MainWindow()
win.show()
app.connect(app, SIGNAL("lastWindowClosed()")
, app
, SLOT("quit()")
)
app.exec_loop()
if __name__=="__main__":
main(sys.argv)
Pas mal du tout ta petite bidouille :super:
Merci beaucoup 
Je trouve que c’est un peu dommage de devoir faire ça pour simplement déclancher un fonction avec arguements en cliquant sur un bouton. Tout le reste est tellement naturel en pyqt…
v_atekor : Que deviens tu? (en pv si tu veux)