[Tkinter-discuss] Re: tkinter pmw notebook

Martin Franklin mart.franklin at gmail.com
Thu Apr 21 00:11:50 CEST 2005

dimitri pater wrote:
> Hello,
> yes thanks, I have tried the raisecommand, but it doesn't seem to work 
> and I can't find any clear examples.
> I am not sure what "the function is called with a single argument, which 
> is the name of the selected page." means exactly...

The function name you bind to the raisecommand will be called when you
raise a page of the notebook and at the same time the name of the page
will be sent to it

> This is what I do (wrong):
> class Notebook:
>     def __init__(self, parent):
>          notebook = Pmw.NoteBook(parent, raisecommand=self.refreshDB())

Here is one problem, you are calling self.refreshDB() remove
the () and it will bind the name of that method to the raisecommand

>         notebook.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
>         page = notebook.add('Project')
>         page = notebook.add('Database')
>         b = Tkinter.Button(self.frame2, text='Refresh', width=25, 
> underline=0, command=self.refreshDB)
>         b.pack(side="left", padx=2, pady=2)
>     def refreshDB(self):

  Change this to :
       def refreshDB(self, pageName):
           if pageName=="My Interesting Page":
               ## do somthng interesting

> Thanks for you help!
> Dimitri
> On 4/20/05, *Stewart Midwinter* <stewart.midwinter at gmail.com 
> <mailto:stewart.midwinter at gmail.com>> wrote:
>     Grayson's book 'Python & Tkinter Programming'  says that there is a
>     raisecommand option for Notebook:
>     "Specifies a function to call when a new page is selected. the
>     function is called with a single argument, which is the name of the
>     selected page.

Thanks Stuart I was away from a python'ised machine when I wrote my
original reply


More information about the Tkinter-discuss mailing list