createfilehandler, how to use it with Tk?
Fredrik Lundh
fredrik at pythonware.com
Mon Jul 26 11:23:32 EDT 1999
algaba at my-deja.com wrote:
> I have to communicate a tk front end with another modules.
> And I'm trying:
> I've been browsing fnorb example of use of createfilehandler
> but it's as complex as hell.
> has anyone a simple,straightforward example of it?
forget about createfilehandler. use asyncore/asynchat instead:
http://www.python.org/doc/current/lib/module-asyncore.html
to use them under Tk, you can use a
simple polling scheme:
import asyncore
class myApp:
def __init__(self, master):
self.master = master
...
self.poll()
# issue a HTTP request (see handbook example)
http_client("www.python.org", "/")
def poll(self):
# keep the server up and running
try:
asyncore.poll(0.05)
self.master.after(100, self.poll)
except:
pass # error in network callback
...
</F>
More information about the Python-list
mailing list