Bonjour
j'ai cette erreur quand j'exécute mon script TypeError: 'sip.methoddescriptor' object is not callable
j'ai un fichier mainTab.py :
et l'autre fichier tabTwo.py :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 # -*- coding: utf-8 -*- import sys from PyQt4 import QtCore, QtGui from tabTwo import TabTwo from tabThree import TabThree try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.resize(739, 509) MainWindow.setWindowTitle("MainWindow") self.centralwidget = QtGui.QWidget(MainWindow) self.gridLayout = QtGui.QGridLayout(self.centralwidget) self.mainTab = QtGui.QTabWidget(self.centralwidget) self.tab = QtGui.QWidget() self.v_layout = QtGui.QVBoxLayout(self.tab) self.sub_tab = TabTwo(self.tab)# self.v_layout.addWidget(self.sub_tab) self.mainTab.addTab(self.tab, "Tab 1") self.gridLayout.addWidget(self.mainTab, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_())
l'objectif c'est d'appeler la méthode :maFonction quand je clique sur le bouton
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 # -*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s class TabTwo(QtGui.QTabWidget): def __init__(self, parent): super(TabTwo, self).__init__(parent) #self.layout = QtGui.QVBoxLayout(self) self.page = QtGui.QWidget(parent) self.page2 = QtGui.QWidget(parent) self.addTab(self.page, "sous onglet 1") self.button = QtGui.QPushButton(self.page) self.button.setGeometry(QtCore.QRect(150, 50, 75, 23)) self.button.setObjectName(_fromUtf8("button")) self.button.setText("ok") #self.ParcourirButton.clicked.connect(self.maFonction) #QtCore.QObject.connect(self.ParcourirButton, QtCore.SIGNAL("clicked()"), self.maFonction) #self.ParcourirButton.triggered.connect(self.maFonction) self.ParcourirButton.clicked.connect(self.maFonction) #self.ParcourirButton.clicked.connect(MainWindow.maFonction) def maFonction(self): print "ca marche ! "
merci
Partager