[Tutor] 3 questions for my port scanner project

Alan Gauld alan.gauld at freenet.co.uk
Sun Feb 27 17:00:12 CET 2005


> Here are the questions (-:
> 1. How do I make a progress bar in Tkinter ?

One option:
Use a set up gif images and update the image periodically
OR
Use a canvas and redraw a rectangle slightly larger every
time through the scanning loop.

The first is easiest the second smoother but much more work!

> 2. I got a while loop which does the port scan itself. How can I end
> it while its working ?

The best way is to have the loop running in a seperate thread
to the GUI and checking a flag on each iteration. Then you can
have a stop button on the GUI that sets the flag.
Its generally a bad idea in a GUI to have long running processes
within an event handler, better to put them in a separate thread.
Unfortunately this is a lesson that Microsoft's programmers don't
appear to have learned yet!

Alan G.



More information about the Tutor mailing list