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?