Working with Widget after Instance loses the reference

A

Al in Dallas

I made the mistake of creating an instance of a widget and assigning it
to a name I'd already used. Now, if I use root.children or
root.slaves(), I can see the "lost" widget, but can I do anything else
with the string of numbers that shows up when I use root.children? I'd
like to destory the widget, for example. it would be even better if I
could create a new name and have it reference the "lost" widget.

Of course, I can just kill my toplevel and start over.
 
J

John McMonagle

I made the mistake of creating an instance of a widget and assigning it
to a name I'd already used. Now, if I use root.children or
root.slaves(), I can see the "lost" widget, but can I do anything else
with the string of numbers that shows up when I use root.children? I'd
like to destory the widget, for example. it would be even better if I
could create a new name and have it reference the "lost" widget.

Of course, I can just kill my toplevel and start over.


Consider the following code run in the python shell:
Traceback (most recent call last):
File said:
b1 = r.slaves()[0]
b1.destroy()


So, as long as you know what your widget instance is in root.slaves() or
root.children you can assign it to a new name.
 
A

Al in Dallas

[example of "losing" a widget]
Consider the following code run in the python shell:
Traceback (most recent call last):
File said:
b1 = r.slaves()[0]
b1.destroy()


So, as long as you know what your widget instance is in root.slaves() or
root.children you can assign it to a new name.

Since I've been leaving my shell open, I jumped in and tried:

recoveredlabel = root.slaves()[6]

And after I verified I could manipulate the widget with that
name, I executed:

<original-widget-name> = recoveredlabel

Now the only difference between where I was (before I screwed up)
and where I am is that I've got this extra variable named
"recoveredlabel."

Thanks.

Now, do you have any advice on learning the syntax for dealing
with Tix megawidgets in Python? I guess my alternative is to
learn how to use Elmer or SWIG so I can hide all the Python
I've inherited "under the hood" and write my GUI in Tcl/Tk.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top