tkinter call backs
Gordon Williams
g_will at cyberus.ca
Mon Jul 19 13:40:43 EDT 1999
Hi,
In fileopen(), root is a unknown name because (I believe) I dont pass root
to it. Fileopen() is a call back (and I dont know how to pass an instance
or variable through a call back). I get an name error when I then use
fileName=tkFileDialog.askopenfilename(parent=root, title="Open")
This part is in a module to make a menu. When the module is tested by
itself it runs fine and root does not give and error. print root returns .
(period). When the module is imported into the main module and then used,
I now get an error. root=Tk() is defined in the main module. Is this a
problem of local and global names? How do I overcome it?
Fredrik Lundh <fredrik at pythonware.com> wrote in article
<00ca01bed209$5543adf0$f29b12c2 at secret.pythonware.com>...
> Gordon Williams <g_will at cyberus.ca> wrote:
> > I have a simple problem that I cant find the solution. I have a menu
item
> > to open a file which has a command "openfile". I would like to
activate
> > "tkFileDialog.askopenfilename" to get the name of the file. This
requires
> > "parent=root" or something like that for the position of the message
box.
> >
> > How do I pass "root" into openfile?
>
> after which he promptly answered his own
> question:
>
> > fileName=tkFileDialog.askopenfilename(parent=root, title="Open")
>
> what am I missing here?
>
> </F>
>
>
More information about the Python-list
mailing list