[Tutor] More Tkinter Help Please [Dialog windows]

SA sarmstrong13@mac.com
Tue, 18 Jun 2002 14:50:34 -0500


On 6/18/02 11:07 AM, "alan.gauld@bt.com" <alan.gauld@bt.com> wrote:

>    def doSave(self):        # inside Pyshell class
>        saveDialog = Saving(f) # auto calls apply etc
>        filename = saveDialog.getName()
>        self.saveText(filename)
>        del(saveDialog)
A couple of things here:

    I can't use self in "def doSave(self):" because the doSave function is
actually inside PyShell.__iniT__. If I use self and place this function
inside PyShell but outside of __init__ I get an error claiming the function
is asking for on arument but none are given. If I place the function inside
__init__ everything works except for the "self.saveText(filename)" portion
because there is no instance of self inside the function?

So I tried to fiddle around with this function and have the following:

def doSave():
    SaveDialog = Saving(top)
    filename = SaveDialog.getName()
    outfile = t1()
    out = open(filename, 'w')
    inf = open(outfile, 'r')
    for line in inf.readlines():
        out.write(line)
    out.close()

Now this actually brings up the popup save dialog and allows the user to
chose the directory path and filename, even writes the correct file in the
correct place, but there is no data in the file. It is not placing the t1
object's data into the outfile as a string.

So I guess my final question is how do I coerce t1 to give its data to
outfile as a string?

Thanks.
SA