Hello I am building a simple python app to further educate myself.<br><br>I am almost some what complete with this application. However I can not think how to add more than one entry to a TextBox. So when I input the first value it stays and then the second value third and so forth right now it replaces the first value with the second etc etc<br>
<br>Here is my app code<br><br>#PYTHON#<br><br><br>import clr<br>clr.AddReference("PresentationFramework")<br>clr.AddReference("PresentationCore")<br><br>from System.IO import File<br>from System.Windows.Markup import XamlReader<br>
from System.Windows import *<br><br>import socket<br>from threading import *<br>import cPickle<br><br>CMD_MSG = range(1)<br><br>class Chat(object):<br> def __init__(self):<br> mythread = Thread(target=self.server)<br>
mythread.start() <br> stream = File.OpenRead("p2pChat.xaml")<br> self.root = XamlReader.Load(stream) <br> self.ip_address_input = self.root.FindName('ip_address') <br>
self.sendB = self.root.FindName('send')<br> self.output = self.root.FindName('textbox')<br> self.entry_input = self.root.FindName('entry')<br> self.sendB.Click += self.sendit<br>
<br> def server(self):<br> self.port = 9000<br> self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)<br> self.s.bind((socket.gethostbyname(socket.gethostname()), int(self.port)))<br> #print socket.gethostbyname(socket.gethostname())<br>
while True:<br> msg, addr = self.s.recvfrom(2024)<br>## cmd, msg = ord(msg[0]),msg[1:]<br>## if cmd == CMD_MSG:<br> self.output.Text = str(msg) + "\n"<br> <br> def client(self, msg):<br>
self.port = 9000<br> self.host = self.ip_address_input.Text<br> <a href="http://self.se">self.se</a> = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)<br> self.se.sendto(str(self.host) + " : " + msg, (self.host, int(self.port)))<br>
<br> def sendit(self, s, e):<br> self.client(str(self.entry_input.Text))<br> self.output.Text = str(self.entry_input.Text + "\n")<br> self.entry_input.Text = ""<br><br><br><br>myChat = Chat()<br>
<br><br>app = Application()<br>app.Run(myChat.root)<br><br>Thanks in advance :-)<br><br><br>