c'est une turie git add .!
This commit is contained in:
parent
384b0514c5
commit
270a10de1b
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'mainWindow.ui'
|
||||
#
|
||||
# Created: Tue Mar 31 12:14:51 2015
|
||||
# Created: Fri Apr 3 14:33:44 2015
|
||||
# by: PyQt4 UI code generator 4.11.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
@ -73,14 +73,33 @@ class Ui_Dialog(object):
|
||||
self.pushButton.setObjectName(_fromUtf8("pushButton"))
|
||||
self.horizontalLayout.addWidget(self.pushButton)
|
||||
self.horizontalLayoutWidget_2 = QtGui.QWidget(Dialog)
|
||||
self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(470, 20, 291, 51))
|
||||
self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(20, 40, 741, 51))
|
||||
self.horizontalLayoutWidget_2.setObjectName(_fromUtf8("horizontalLayoutWidget_2"))
|
||||
self.horizontalLayout_2 = QtGui.QHBoxLayout(self.horizontalLayoutWidget_2)
|
||||
self.horizontalLayout_2.setMargin(0)
|
||||
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
|
||||
self.label_3 = QtGui.QLabel(self.horizontalLayoutWidget_2)
|
||||
self.label_3.setObjectName(_fromUtf8("label_3"))
|
||||
self.horizontalLayout_2.addWidget(self.label_3)
|
||||
self.lineEdit_4 = QtGui.QLineEdit(self.horizontalLayoutWidget_2)
|
||||
self.lineEdit_4.setInputMask(_fromUtf8(""))
|
||||
self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4"))
|
||||
self.horizontalLayout_2.addWidget(self.lineEdit_4)
|
||||
self.label_4 = QtGui.QLabel(self.horizontalLayoutWidget_2)
|
||||
self.label_4.setObjectName(_fromUtf8("label_4"))
|
||||
self.horizontalLayout_2.addWidget(self.label_4)
|
||||
self.lineEdit_3 = QtGui.QLineEdit(self.horizontalLayoutWidget_2)
|
||||
self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3"))
|
||||
self.horizontalLayout_2.addWidget(self.lineEdit_3)
|
||||
self.label_5 = QtGui.QLabel(self.horizontalLayoutWidget_2)
|
||||
self.label_5.setObjectName(_fromUtf8("label_5"))
|
||||
self.horizontalLayout_2.addWidget(self.label_5)
|
||||
self.lineEdit_2 = QtGui.QLineEdit(self.horizontalLayoutWidget_2)
|
||||
self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
|
||||
self.horizontalLayout_2.addWidget(self.lineEdit_2)
|
||||
self.pushButton_6 = QtGui.QPushButton(self.horizontalLayoutWidget_2)
|
||||
self.pushButton_6.setObjectName(_fromUtf8("pushButton_6"))
|
||||
self.horizontalLayout_2.addWidget(self.pushButton_6)
|
||||
self.pushButton_3 = QtGui.QPushButton(self.horizontalLayoutWidget_2)
|
||||
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
|
||||
self.horizontalLayout_2.addWidget(self.pushButton_3)
|
||||
@ -114,7 +133,7 @@ class Ui_Dialog(object):
|
||||
self.txtOutput.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
|
||||
self.txtOutput.setObjectName(_fromUtf8("txtOutput"))
|
||||
self.label_2 = QtGui.QLabel(Dialog)
|
||||
self.label_2.setGeometry(QtCore.QRect(30, 30, 421, 31))
|
||||
self.label_2.setGeometry(QtCore.QRect(20, 10, 171, 31))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(16)
|
||||
font.setBold(True)
|
||||
@ -130,6 +149,13 @@ class Ui_Dialog(object):
|
||||
self.label.setText(_translate("Dialog", "Nick list", None))
|
||||
self.listNames.setSortingEnabled(True)
|
||||
self.pushButton.setText(_translate("Dialog", "Send message", None))
|
||||
self.label_3.setText(_translate("Dialog", "IP : ", None))
|
||||
self.lineEdit_4.setText(_translate("Dialog", "127.0.0.1", None))
|
||||
self.label_4.setText(_translate("Dialog", "Port :", None))
|
||||
self.lineEdit_3.setText(_translate("Dialog", "2222", None))
|
||||
self.label_5.setText(_translate("Dialog", "Pseudo :", None))
|
||||
self.lineEdit_2.setText(_translate("Dialog", "anonymous", None))
|
||||
self.pushButton_6.setText(_translate("Dialog", "Change pseudo", None))
|
||||
self.pushButton_3.setText(_translate("Dialog", "Disconnect", None))
|
||||
self.pushButton_2.setText(_translate("Dialog", "Connect", None))
|
||||
self.pushButton_5.setText(_translate("Dialog", "Disable", None))
|
||||
|
@ -118,13 +118,51 @@
|
||||
<widget class="QWidget" name="horizontalLayoutWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>20</y>
|
||||
<width>291</width>
|
||||
<x>20</x>
|
||||
<y>40</y>
|
||||
<width>741</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>IP : </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_4">
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>127.0.0.1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Port :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_3">
|
||||
<property name="text">
|
||||
<string>2222</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Pseudo :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2">
|
||||
<property name="text">
|
||||
@ -132,6 +170,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<property name="text">
|
||||
<string>Change pseudo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="text">
|
||||
@ -222,9 +267,9 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>30</y>
|
||||
<width>421</width>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>171</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -2,12 +2,12 @@ from mainWindow import Ui_Dialog
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from PySide.QtCore import *
|
||||
from PySide.QtGui import *
|
||||
import time, threading, datetime, time
|
||||
import time, threading, datetime, time, random
|
||||
from socket import *
|
||||
|
||||
Host = "127.0.0.1"
|
||||
Port = 2222
|
||||
Addr = (Host, Port)
|
||||
|
||||
|
||||
|
||||
class MySignal(QObject):
|
||||
@ -75,22 +75,34 @@ class start(QtGui.QDialog):
|
||||
|
||||
def ShowMessageErreur(self, txt):
|
||||
self.message_buffer += '<br> <span style="color : red; font-weight: bold;"> '+ self.htmlToText(txt) +' </span>'
|
||||
|
||||
def ShowMessageOK(self, txt):
|
||||
self.message_buffer += '<br> <span style="color : green; font-weight: bold;"> '+ self.htmlToText(txt) +' </span>'
|
||||
|
||||
def ShowMessageAsText(self, txt):
|
||||
|
||||
|
||||
self.message_buffer += '<br> <span style="color : #E6E6E6"> '+ txt +' </span>'
|
||||
self.message_buffer += '<br> <span style="color : #E6E6E6"> '+ txt.split(" ")[0] +' </span>'
|
||||
|
||||
|
||||
|
||||
if txt.split(" ")[0] == "SUCCESSFUL_LOGOUT" :
|
||||
self.ShowMessageOK("Sucessful logout !")
|
||||
|
||||
if txt.split(" ")[0] == "SUCC_VALID_NICKNAME" :
|
||||
self.ShowMessageOK("Sucessful nickname change !")
|
||||
|
||||
|
||||
|
||||
if txt.split(" ")[0] == "NAME_CHANGED" :
|
||||
self.ShowMessageNameChange(txt.split(" ")[1], txt.split(" ")[2])
|
||||
|
||||
if txt.split(" ")[0] == "HAS_JOIN" :
|
||||
self.ShowMessageHasJoin(txt.split(" ")[1])
|
||||
|
||||
if txt.split(" ")[0] == "SUCC_CHANNEL_JOINED" :
|
||||
if txt.split(" ")[0] == "SUCC_CHANNEL_JOINED" or txt.split(" ")[0] == "SUCC_CHANNEL_JOINEDUSERLIST" :
|
||||
self.ShowMessageHasJoin(self.pseudo)
|
||||
|
||||
|
||||
|
||||
if txt.split(" ")[0] == "NEW_MSG" :
|
||||
self.message_buffer += '<br><span style="color : grey"> ' + self.getTimeStamp() + '</span> <span style="color : red"> < '+txt.split(" ")[1] +' > </span> ' + self.htmlToText(' '.join(txt.split(" ")[2:])) + ''
|
||||
@ -121,9 +133,34 @@ class start(QtGui.QDialog):
|
||||
self.ui.pushButton_2.clicked.connect(self.connecter)
|
||||
self.ui.pushButton_3.clicked.connect(self.deco)
|
||||
self.ui.pushButton.clicked.connect(self.client)
|
||||
self.ui.pushButton_6.clicked.connect(self.changeN)
|
||||
|
||||
def changeN(self):
|
||||
changePseudo = self.ui.lineEdit_2.text()
|
||||
cmdChange = "/name "+changePseudo
|
||||
try:
|
||||
self.s.send(cmdChange.encode())
|
||||
self.pseudo = changePseudo
|
||||
|
||||
|
||||
except timeout:
|
||||
self.ShowMessageErreur("Erreur : Timeout. Le serveur ne repond pas")
|
||||
self.ui.txtOutput.setText(self.message_buffer)
|
||||
sb = self.ui.txtOutput.verticalScrollBar()
|
||||
sb.setValue(sb.maximum())
|
||||
|
||||
|
||||
|
||||
def connecter(self):
|
||||
#lineEdit_2
|
||||
|
||||
ip= self.ui.lineEdit_4.text()
|
||||
port = int(self.ui.lineEdit_3.text())
|
||||
if ip is None or port is None :
|
||||
Addr = (Host, Port)
|
||||
else :
|
||||
Addr = (ip,port)
|
||||
|
||||
|
||||
self.s = socket(AF_INET, SOCK_STREAM)
|
||||
self.s.connect(Addr)
|
||||
self.thread.setConfig(self.s,self)
|
||||
@ -132,13 +169,34 @@ class start(QtGui.QDialog):
|
||||
self.ui.pushButton_2.setDisabled(True)
|
||||
self.ui.pushButton_3.setDisabled(False)
|
||||
self.thread.start()
|
||||
|
||||
|
||||
cmd2 = self.ui.lineEdit_2.text()
|
||||
if cmd2 != "":
|
||||
self.s.settimeout(5.0)
|
||||
cmdPseudo = "/newname "+cmd2
|
||||
try:
|
||||
self.s.send(cmdPseudo.encode())
|
||||
self.pseudo = cmd2
|
||||
self.ui.pushButton_6.setDisabled(False)
|
||||
|
||||
|
||||
except timeout:
|
||||
self.ShowMessageErreur("Erreur : Timeout. Le serveur ne repond pas")
|
||||
self.ui.txtOutput.setText(self.message_buffer)
|
||||
sb = self.ui.txtOutput.verticalScrollBar()
|
||||
sb.setValue(sb.maximum())
|
||||
|
||||
|
||||
def deco(self):
|
||||
self.s.close()
|
||||
quitter = "/quit"
|
||||
self.s.send(quitter.encode())
|
||||
#self.s.close()
|
||||
self.ui.lineEdit.setDisabled(True)
|
||||
self.ui.pushButton.setDisabled(True)
|
||||
self.ui.pushButton_2.setDisabled(False)
|
||||
self.ui.pushButton_3.setDisabled(True)
|
||||
self.ui.pushButton_6.setDisabled(True)
|
||||
|
||||
def ecoute(self):
|
||||
while 1 :
|
||||
@ -159,10 +217,15 @@ class start(QtGui.QDialog):
|
||||
self.ui = Ui_Dialog()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
ano = "anonymous" + ''.join(str(random.randint(1,9)) for _ in range(2))
|
||||
self.ui.lineEdit_2.setText(ano)
|
||||
|
||||
self.ui.lineEdit.setDisabled(True)
|
||||
self.ui.pushButton.setDisabled(True)
|
||||
self.ui.pushButton_3.setDisabled(True)
|
||||
self.ui.pushButton_6.setDisabled(True)
|
||||
self.message_buffer = ""
|
||||
|
||||
self.connectActions()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user