Yay ty worked perfectly *cheers Thanks a bunch
Andrew On Sun, Jul 11, 2010 at 2:10 PM, Michael Foord <fuzzy...@voidspace.org.uk>wrote: > On 11/07/2010 22:06, Andrew Evans wrote: > > Hello I am building a simple python app to further educate myself. > > 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 > > > You currently have this for setting the text in the textbox: > > > self.output.Text = str(self.entry_input.Text + "\n") > > This replaces the current text with next text. Instead try: > > self.output.Text += (self.entry_input.Text + "\n") > > No need for the call to str - the Text property of a textbox is already a > string. > > All the best, > > Michael > > > > Here is my app code > > #PYTHON# > > > import clr > clr.AddReference("PresentationFramework") > clr.AddReference("PresentationCore") > > from System.IO import File > from System.Windows.Markup import XamlReader > from System.Windows import * > > import socket > from threading import * > import cPickle > > CMD_MSG = range(1) > > class Chat(object): > def __init__(self): > mythread = Thread(target=self.server) > mythread.start() > stream = File.OpenRead("p2pChat.xaml") > self.root = XamlReader.Load(stream) > self.ip_address_input = self.root.FindName('ip_address') > self.sendB = self.root.FindName('send') > self.output = self.root.FindName('textbox') > self.entry_input = self.root.FindName('entry') > self.sendB.Click += self.sendit > > def server(self): > self.port = 9000 > self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > self.s.bind((socket.gethostbyname(socket.gethostname()), > int(self.port))) > #print socket.gethostbyname(socket.gethostname()) > while True: > msg, addr = self.s.recvfrom(2024) > ## cmd, msg = ord(msg[0]),msg[1:] > ## if cmd == CMD_MSG: > self.output.Text = str(msg) + "\n" > > def client(self, msg): > self.port = 9000 > self.host = self.ip_address_input.Text > self.se = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > self.se.sendto(str(self.host) + " : " + msg, (self.host, > int(self.port))) > > def sendit(self, s, e): > self.client(str(self.entry_input.Text)) > self.output.Text = str(self.entry_input.Text + "\n") > self.entry_input.Text = "" > > > > myChat = Chat() > > > app = Application() > app.Run(myChat.root) > > Thanks in advance :-) > > > > _______________________________________________ > Users mailing > listus...@lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > -- http://www.ironpythoninaction.com/http://www.voidspace.org.uk/blog > > READ CAREFULLY. By accepting and reading this email you agree, on behalf of > your employer, to release me from all obligations and waivers arising from > any and all NON-NEGOTIATED agreements, licenses, terms-of-service, > shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, > non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have > entered into with your employer, its partners, licensors, agents and assigns, > in perpetuity, without prejudice to my ongoing rights and privileges. You > further represent that you have the authority to release me from any BOGUS > AGREEMENTS on behalf of your employer. > > > > _______________________________________________ > Users mailing list > Users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com