[Tutor] deleting CR within files

Alan Gauld alan.gauld at blueyonder.co.uk
Tue Apr 20 14:23:28 EDT 2004


David,

This is a reply to the code you posted today, unfortunately the
mail tool I'm using doesn't work properly with the digest! :-(

I think you need to look at the structure of your code.
Here is what I think you are trying to do?

You want to build a GUI that has 3  buttons.
One of them will bring up a file dialog from which the
	user selects a file for processing.
On closing the file you process the selected file
The user can select another file by repeating the above process.
	(as someone else pointed out, your user may select multiple
	files in which case you need a loop to process them and the
	correct one to choose is probably a for loop.)

If I got the idea right then you need:
1) a function to display the file dialog(you got it is dialog())
2) a function to process a single file
3) an event handler to call the dialog() function to store the
    result in a global variable and then call the file
    processing function - you almost got it, its doDialog()
4) a function to define the GUI widgets and pack them into
    the top level window, binding the doDialog function to the
    Choose files button. (I can't recall what the middle button was...)
5) a GUI mainloop, which you get for free with Tk.mainloop()

It should just be a case of assembling the bits and letting
Tkinter do its stuff, you do not need to call any of the above
functions except the GUI building one from your main program
and doDialog() calls both dialog() and processFile() internally.

Does that help? Have I understood what you are trying to do?

Alan G.
(Normal service resumed on Thursday!:-)




More information about the Tutor mailing list