[pygtk] Refresh window
Genie Fomina
fgenie at gmail.com
Sat Dec 3 06:03:52 WST 2005
John, my problem is not about reading from sockets (this part works good),
and I do not have anything that should be done fair amount of time, it's
more about writing into sockets (to two of them I need to write too). I add
sockets by gobject.io_add_watch(sock,gobject.IO_IN | gobject.IO_OUT,
self.my_callback) and so main loop always calls the callbacks because those
sockets are always ready to be written to. So I understand those callbacks
always in pending_events(). And what I have as a result is that one callback
get called all the time when another one never/rarely. Sometimes it works ok
but I need a stable result and I really need to uderstand where is the right
place to put
while/if gtk.events_pending():
gtk.main_iteration()
Another quesion, is there a way to call a callback to write into a socket
only when I have data to write? Do I have to use io_add_watch method to
write into a socket or it will be better without it?
Thank you, Genie
On 12/1/05, John Ehresman <jpe at wingware.com> wrote:
>
> Genie Fomina wrote:
> > Gustavo, thank you for your reply, that looks promising. But it requires
> > pygtk 2.8 for some reason. I am not sure I will be able to use this
> > version everywhere I will put my application to. There might be 2.6 or
> > even 2.4 versions. What is the right way of working with sockets and
> > refreshing windows in these versions?
>
> Is your problem reading everything from a socket or doing something else
> that requires a fair amount of time? If it is reading from a socket,
> structure your program to only read whatever is available in a callback
> then return and let the mainloop call you again when there's more to
> read. If the problem is doing something else, break the task up into
> multiple steps and the schedule an idle or timeout for each one.
>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20051202/2a3ff7f6/attachment.htm
More information about the pygtk
mailing list