Re: Dealing with a Tk reference

Michael Lange <[email protected]>
Newsgroups gmane.comp.python.tkinter
Message-ID <[email protected]>
Hi,

On Sun, 4 Sep 2016 10:56:20 -0300
Cam Farnell <[email protected]> wrote:

(...)
> In my application it is not convenient to keep the reference to the
> Menu in self.menuBar. Later when it comes time to add another another
> cascade to the menu I was hoping to be able access the menu bar using:
> 
>      menuBar = top['menu']
> 
> but in fact having done that, menuBar not a tk.Menu object as I was
> hoping but rather a string, such as ".3070843372L", which is presumably
> a reference to a tk object.
> 
> So my question is: how to use the string to access the corresponding
> tk.Menu object? There's probably some magic way to do that but a bunch
> of internet searching didn't turn it up.

to convert the widget name into a Widget object you will need the
nametowidget method, as in

menubar = top.nametowidget(top['menu'])

Best regards

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

No one may kill a man.  Not for any purpose.  It cannot be condoned.
		-- Kirk, "Spock's Brain", stardate 5431.6
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.