accessing child Pmw elements

Matthew Bull matt at fusion4.co.uk
Mon Aug 7 12:47:36 EDT 2000


Richard Chamberlain wrote:

> Matthew Bull wrote:
> > 
> > Hi all,
> > 
> > a quick newbie question how would I access a tk widget which is the
> > child of a Pmw Notebook widget??
> > 
> > I've already tried using page() to access the parent but couldn't access
> > the child text element it contained.
> > 
> > Does anyone know a quick and easy way of accessing these from the toplevel??
> > 
> > Matt
> 
> 
> Hi Matthew,
> 
> I may have missed your point, so let me know if I have :) but,
> 
> As long as you keep a reference to your widget you can access it
> directly, so:
> 
> from Tkinter import *
> import Pmw
> root=Tk()
> Pmw.initialise()
> notebook=Pmw.Notebook(root)
> notebook.pack()
> page=notebook.add('My Tab')
> entry=Entry(page,width=20)
> entry.pack()
> root.mainloop()
> 
> Obviously you've now got a reference to your Entry, i.e.
> entry.config(fg='red')
> 
> Richard
Hmmnn Possibly, I was more looking for a way without having to track the 
elements myself as the widget already seems to do it, I don't want to 
access all the elements just the one on the top hence my trying to use 
page()==>
self.notebook=Pmw.Notebook(root,raisecommand=link)
def link(self,active):
	frame=self.notebook.page(active)
	......
then get the child element from that but yes I could pop them all into a 
dictionary and access them that way I was just looking for an easier 
(more elegant???) way.

grats for the help

matt




More information about the Python-list mailing list