Bonjour,

Voici mon problème : j'utilise Python 2.7 et PyQt4, j'ai un bouton start qui, lorsque je clique dessus, me permet de lancer un script et de récupérer une valeur entrée dans un line edit. Mon soucis c'est que je suis confronté à une erreur 'TypeError: run() takes exactly 2 arguments (1 given)'. Cela va vous paraitre surement ridicule mais je ne vois pas du tout ce qui cause cette erreur, car pour moi ma méthode me semble tout a fait normale. Si quelqu'un pourrait m'aider là-dessus, je lui en serait très reconnaissant !

Voici le code :

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
class Conf_Tab(QWidget):
    def __init__(self, parent = None):
 
        super(Conf_Tab,self).__init__()
        self.Dis = Table()
        self.Inp = Table()
        self.Pro = Table()
 
        label1 = QLabel('<strong>Dispatcher</strong>')
        label2 = QLabel('<strong>Input</strong>')
        label3 = QLabel('<strong>Projection<strong>')
 
        self.select = QComboBox()
        backends = list(backend.lower() for backend in BINoculars.util.get_backends())
        self.select.addItems(QStringList(backends))
        self.start = QPushButton('run')
        self.connect(self.start, SIGNAL("clicked()"), self.run)
        self.scan = QLineEdit()
        self.start.setStyleSheet("background-color: darkred")
 
        Layout = QGridLayout()
        Layout.addWidget(self.select,0,1)
        Layout.addWidget(label1,1,1)
        Layout.addWidget(self.Dis,2,1)
        Layout.addWidget(label2,3,1)
        Layout.addWidget(self.Inp,4,1)
        Layout.addWidget(label3,5,1)
        Layout.addWidget(self.Pro,6,1) 
        Layout.addWidget(self.start,7,0)
        Layout.addWidget(self.scan,7,1)
        self.setLayout(Layout)
 
        self.Dis.add_to_combo(QStringList(BINoculars.util.get_dispatchers()))
        self.select.activated['QString'].connect(self.DataCombo)
        self.Inp.combobox.activated['QString'].connect(self.DataTableInp)
        self.Pro.combobox.activated['QString'].connect(self.DataTableInpPro)
        self.Dis.combobox.activated['QString'].connect(self.DataTableInpDis)
 
 
    def DataCombo(self,text):
        self.Inp.add_to_combo(QStringList(BINoculars.util.get_inputs(str(text))))
        self.Pro.add_to_combo(QStringList(BINoculars.util.get_projections(str(text))))
 
    def DataTableInp (self,text):
        backend = str(self.select.currentText())
        inp = BINoculars.util.get_input_configkeys(backend, str(self.Inp.combobox.currentText()))
        self.Inp.addDataConf(inp)
 
    def DataTableInpPro (self,text):
        backend = str(self.select.currentText())
        proj = BINoculars.util.get_projection_configkeys(backend, str(self.Pro.combobox.currentText()))
        self.Pro.addDataConf(proj)
 
    def DataTableInpDis (self,text):
        backend = str(self.select.currentText())
        disp = BINoculars.util.get_dispatcher_configkeys(str(self.Dis.combobox.currentText()))
        self.Dis.addDataConf(disp)
 
 
    def save(self, filename): 
        with open(filename, 'w') as fp:
            fp.write('[dispatcher]\n')
            for key, value, comment in self.Dis.getParam():# cycles over the iterator object
                fp.write('{0} = {1} #{2}\n'.format(key, value, comment))
            fp.write('[input]\n')
            for key, value, comment in self.Inp.getParam():
                if key == 'type':
                    value = '{0}:{1}'.format(self.select.currentText(),value)
                fp.write('{0} = {1} #{2}\n'.format(key, value, comment))
            fp.write('[projection]\n')
            for key, value, comment in self.Pro.getParam():
                if key == 'type':
                    value = '{0}:{1}'.format(self.select.currentText(),value)
                fp.write('{0} = {1} #{2}\n'.format(key, value, comment))
 
    def get_configobj(self, filename):
        indict = {}
        for key, value, comment in self.Inp.getParam():
            if key == 'type':
                value = '{0}:{1}'.format(self.select.currentText(),value)
                indict[key] = value
 
 
        for key, value, comment in self.Dis.getParam():
            if key == 'type':
                value = '{0}:{1}'.format(self.select.currentText(),value)
                indict[key] = value
 
 
        for key, value, comment in self.Pro.getParam():
            if key == 'type':
                value = '{0}:{1}'.format(self.select.currentText(),value)
                indict[key] = value
 
 
        cfg = BINoculars.util.Configfile()
        setattr(cfg, 'input', indict)
        setattr(cfg, 'dispatcher', indict)
        setattr(cfg, 'projection', indict)
        return cfg
 
    def read_data(self,filename):
        with open(filename, 'r') as inf:
            lines = inf.readlines()
 
        data = {'dispatcher': [], 'input': [], 'projection': []}
        for line in lines:
            line = line.strip('\n')
            if '[dispatcher]' in line:
                key = 'dispatcher'
            elif '[input]' in line:
                key = 'input'
            elif '[projection]' in line: 
                key = 'projection'
            else:
                if '#' in line:
                    index = line.index('#')
                    caput = line[:index]
                    cauda = line[index:]
                else:
                    caput = line
                    cauda = ''
                if '=' in caput:
                    name, value = caput.split('=')
                    if name.strip(' ') == 'type' and ':' in value:
                        backend, value = value.strip(' ').split(':')
                    data[key].append([name.strip(' '), value.strip(' '), cauda.strip(' ')])
 
        self.select.setCurrentIndex(self.select.findText(backend, Qt.MatchFixedString))
        self.DataCombo(backend)
 
        for key in data:
            if key == 'dispatcher':
                self.Dis.addData(data[key])
            elif key == 'input':
                self.Inp.addData(data[key])
            elif key == 'projection':
                self.Pro.addData(data[key])
 
 
    def run(self,cfg):
        command = self.scan.text()
        BINoculars.main.Main.from_object(cfg, command)