writing a chat program

Erlend J. Leiknes nookieNO_SP_AM at online.no
Tue Jun 4 12:45:37 EDT 2002


Here is a little thread for you my friend:

import thread
class MyClass:
    def __init__(self):
        self._running = 0

    def Start(self):
        if self._running = 0:
            self._running = 1
            thread.start_new_thread(_MyThreadFunction,())

    def Stop(self):
        self._running = 0

    def _MyThreadFunction(self):
        while self._running:
            #put your function here
            pass

MyFunc = MyClass()
MyFunc.start()
while 1:
    import time
    time.sleep(1)


"Shaun Whelden" <shaunw at liberateschool.com> wrote in message
news:d4c18195.0206040840.7ece1b8c at posting.google.com...
> Hi all,
> I'm trying to throw together a simple text-based chat program in
> Python.  Here's the problem I have right now: I need a way to allow
> the user to be entering in a message they want to send, while at the
> same time waiting for any data that may come through the socket.  If
> data does come through the socket, I need the user to be able to
> continue typing while the data is printed to the screen.
>
> I'm writing this on a Windows machine, so curses is out of the
> question.  Also, I want this to be a text based program, so I don't
> want to have to mess around with Tkinter or any other forms of GUI
> unless I have to.  I'm pretty sure that I need to do something
> involving thread.py and/or threading.py, but I've never used a thread
> before in my life.  Can anyone help?
>
> Shaun Whelden
> shaunw at liberateschool.com





More information about the Python-list mailing list