Bonjour,

J'essaye de remplir un QPlainTextEdit à partir d'un autre thread, alors il parait qu'il faut utiliser les signaux et les slots pour ça ; mais comme je débute, évidemment, ça ne marche pas : rien n'est affiché.

Mon code peut se résumer à ceci : (il a peut-être l'air un peu sale comme ça, mais c'est parce que j'en ai retiré tout ce qui est inutile)
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
import threading
from PyQt4 import QtCore, QtGui
 
class Ui_window(object):
    def setupUi(self, window):
        window.setObjectName("window")
        window.resize(761, 591)
        self.commandsHistory = QtGui.QPlainTextEdit(self.window)
        self.commandsHistory.setObjectName("commandsHistory")
 
 
def printer(window):
    window.emit(QtCore.SIGNAL('printReply(%s)' % row))
 
class Window(QtGui.QTabWidget, window.Ui_window):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.setupUi(self)
 
        self.connect(self, QtCore.SIGNAL('printReply()'),
                     self.commandsHistory, QtCore.SLOT('appendPlainText()'))
 
        threading.Thread(target=getReplies, args=(self,),
                         name='Fetch replies').start()
 
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
 
    w = Window()
    w.show()
 
    sys.exit(app.exec_())
Merci d'avance,
ProgVal