[Tutor] More Tkinter Help Please [Dialog windows]
alan.gauld@bt.com
alan.gauld@bt.com
Tue, 18 Jun 2002 10:48:23 +0100
> The Dialog box is now popping up like it should. The only
> problem comes when I click on OK in the dialog box.
> Instead of saving the text in t1 to the file it gives
> ...
> AttributeError: Saving instance has no attribute 't1'
>
>
> I would of thought that t1 is still defined from PyShell when
> called in the class Saving since it is being called in PyShell
Nope, the new instance has no knoiwledge of whats in Pyshell
- that's object encapsulation at work.
You will have to pass either a reference to PyShell to Saving
(Which you do already via the f constructor parameter) and
then access t1 via that refe5rence or pass the t1 string
directly to Saving.
However as I said in my message yesterday the conventional way
to do this is for SAving to pass back the filename/path to
PyShell and let it save the data - PyShell owns the t1 text
so it should be responsible for saving it. The dialog's
responsibility is limited to getting the right file location
from the user - thats why its called a "dialog"!
Alan G.