I have written a basic python socket based chat program (My second one) and i would like to add some visuals to make it a little more user friendly.
Should I layer the visuals over the existing program or should i make a new program around the visuals
What python module should i use for the visuals (i know pygame is that suitable)
Can i have some form of general idea on how to write this (Code examples maybe?)
Here is my existing code:
Client:
import socket, threading
#Setup The Variables
WindowTitle = 'Chat 2.0 - Client'
s = socket.socket()
host = raw_input("Please Enter External IP adress Here: ")
print
host = socket.gethostname()
port = 8008
#Attempted To Connect
print "Conecting..."
print
while True:
try:
s.connect((host, port))
break
except:
pass
print "Connected To " + str(host) + " " + str(port)
print
#Check For Incomming Data
def check_for_data():
while True:
data = s.recv(1024)
if data:
print
print "Other: " + str(data)
print
print "You: "
else:
print "Client closed connection"
s.close()
break
#Send Data
def send_data():
while True:
user_input = raw_input("You: ")
print
s.sendall(user_input)
#Start Threads \ Main Loop
t = threading.Thread(target=send_data)
t.daemon = True
t.start() #1
check_for_data()
s.close
Server:
import socket, threading
#Setup The Variables
WindowTitle = 'Chat 2.0 - Client'
host = socket.gethostname()
port = 8008
s = socket.socket()
s.bind((host, port))
print "Awaiting Connection..."
print
s.listen(5)
c, addr = s.accept()
print "Connection From: " + str(addr)
print
def check_for_data(c):
while True:
data = c.recv(1024)
if data:
print
print "Other: " + str(data)
print
print "You: "
else:
print "Client closed connection"
c.close()
break
def send_data():
while True:
message = raw_input("You: ")
print
c.sendall(message)
#Start Threads \ Main Loop
t = threading.Thread(target=send_data)
t.daemon = True
t.start() #1
check_for_data(c)
c.close()