ftp get from a Tkinter gui: advice wanted

Russell E. Owen rowen at cesmail.net
Tue Aug 26 22:43:24 CEST 2003


In article <87zniar1iw.fsf at pobox.com>, jjl at pobox.com (John J. Lee) 
wrote:

>"Russell E. Owen" <rowen at cesmail.net> writes:
>
>> I'm writing a Tkinter app (telescope remote controller). The application 
>> presently runs on unix and MacOS X and I think some users will want to 
>> use Windows. It's going just fine, but I'm trying to add the ability to 
>> automatically get images via binary ftp (i.e. as each image is recorded) 
>> and am realizing it's harder than I though.
>> 
>> Ideally, I'd like image download to work like a typical web browser 
>> download: a status window that shows each transfer, how far along it is, 
>> allows the user to cancel it, etc.
>[...]
>
>Not sure what "as each image is recorded" refers to,...

My application causes astronomical images to be written to disk on a 
remote host. My app will then initiate an ftp transfer to retrieve the 
"image" file on the remote host.

>but if you want
>to grab files via ftp, is there anything wrong with (in a separate
>thread, I suppose):
>
>import urllib2
>urllib2.urlopen("ftp://ftp.example.com/pub/rhubarb.txt")

I suspect you're right. I was hoping not to have to write the log window 
from scratch (especially as Tkinter has no good mult-list widget) but am 
plowing ahead.

I'm using urllib.urlopen (urllib supports ftp with password, which I 
need) and have got the basics done, though am about to post a query 
about nonblocking read of the returned file object.

Tkinter file events seem to work on the returned file and this avoids 
the need to use threads, so really the only significant work will be a 
decent GUI for viewing status and allowing transfers to be aborted.

>If you don't mind pulling in more code, no doubt Twisted could do this
>just as simply too, and, I imagine, wouldn't need to use a separate
>thread (never used it, but I know it has support for various common
>GUI event loops).

Yes, the integration with various event loops is a big attraction. I may 
end up there, but so far have been rolling my own code to avoid relying 
on a 3rd party library.

Thank you for your reply!

-- Russell




More information about the Python-list mailing list