[Tutor] More Tkinter Help Please [Dialog windows]
alan.gauld@bt.com
alan.gauld@bt.com
Tue, 18 Jun 2002 17:07:33 +0100
> I'm trying this, but my question is still how do I pass the
> variable sav
> from:
> def apply(self):
> dir = self.e1.get()
> fn = self.e2.get()
> sav = dir + fn
> return sav
There are several options but I'd recommend writing a
method of the Saving class to fetch the filename.
You also need to create a member attriobute of Saving
to store the value of course...
def apply(self): #as above except last line
dir = self.e1.get()
fn = self.e2.get()
self.name = dir + fn # assign to instance variable
def getName(self): # inside Saving class
return self.name # return instance variable
Then when you create the Saving class you assign to
a local variable.
def doSave(self): # inside Pyshell class
saveDialog = Saving(f) # auto calls apply etc
filename = saveDialog.getName()
self.saveText(filename)
del(saveDialog)
> how to pass the variable sav from Saving to PyShell.
Don't pass the data - it belongs to the object. Get the
object to give you the data on request. Thus when you
create the instance of Saving you keep the reference
and use it to ask for the filename.
Alan g.