This commit is contained in:
DonRenando 2015-03-31 18:49:29 +02:00
parent 156165524b
commit e7fa26f63a

View File

@ -19,7 +19,7 @@ class start(QtGui.QDialog):
def ShowMessageAsText(self, txt): def ShowMessageAsText(self, txt):
self.message_buffer += '\n' + self.getTimeStamp() + txt self.message_buffer += '<br><span style="color : red"> ' + self.getTimeStamp() + '</span>' + txt + ''
def createWidgets(self): def createWidgets(self):
@ -29,12 +29,11 @@ class start(QtGui.QDialog):
self.ui.lineEdit.setDisabled(True) self.ui.lineEdit.setDisabled(True)
self.ui.pushButton.setDisabled(True) self.ui.pushButton.setDisabled(True)
self.ui.pushButton_3.setDisabled(True) self.ui.pushButton_3.setDisabled(True)
self.message_buffer = "" self.message_buffer = ""
self.ShowMessageAsText("coucou ! comment ça va ?")
self.connectActions() self.connectActions()
# self.UpdateMainDisplay() # self.UpdateMainDisplay()
def connectActions(self): def connectActions(self):
@ -50,6 +49,22 @@ class start(QtGui.QDialog):
self.ui.pushButton_2.setDisabled(True) self.ui.pushButton_2.setDisabled(True)
self.ui.pushButton_3.setDisabled(False) self.ui.pushButton_3.setDisabled(False)
"""
try :
while 1 :
data = self.s.recv(4096)
if not data :
break
messgServeur = (data.decode())
self.ShowMessageAsText(messgServeur)
self.ui.txtOutput.setText(self.message_buffer)
self.s.close()
except timeout:
print("Erreur : Timeout. Le serveur ne repond pas.")
"""
def deco(self): def deco(self):
self.s.close() self.s.close()
self.ui.lineEdit.setDisabled(True) self.ui.lineEdit.setDisabled(True)
@ -59,18 +74,20 @@ class start(QtGui.QDialog):
def client(self): def client(self):
cmd = self.ui.lineEdit.text() cmd = self.ui.lineEdit.text()
self.ui.lineEdit.setText('') if cmd != "":
if cmd.lower() == "quit": self.ui.lineEdit.setText('')
exit(0) if cmd.lower() == "quit":
try: exit(0)
self.s.send(cmd.encode()) try:
data = self.s.recv(4096) self.s.send(cmd.encode())
messgServeur = (data.decode()) data = self.s.recv(4096)
self.ShowMessageAsText(messgServeur) messgServeur = (data.decode())
self.ui.txtOutput.setText(self.message_buffer) self.ShowMessageAsText(messgServeur)
except timeout: self.ui.txtOutput.setText(self.message_buffer)
print("Erreur : Timeout. Le serveur ne repond pas.") sb = self.ui.txtOutput.verticalScrollBar()
sb.setValue(sb.maximum())
except timeout:
print("Erreur : Timeout. Le serveur ne repond pas.")
if __name__ == "__main__": if __name__ == "__main__":