By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,313 Members | 1,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,313 IT Pros & Developers. It's quick & easy.

[PMW] Rename a notebook's page - how?

P: n/a
Hi again,

I'd like to rename a page of a notebook. Deleting the page and adding a new
one is not really an option, because the page is filled with other controls
already. So I looked into Pmw.Notebook. There are quite a few lists and
dicts which were to be changed and I wasn't successful in the first try.

However, if nobody has ever done this, I'd have to rebuild the whole page
after deleting/adding. I really hope there's an other way to go.

Kind regards
Franz GEIGER



Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Tue, 2003-09-30 at 14:49, F. GEIGER wrote:
Hi again,

I'd like to rename a page of a notebook. Deleting the page and adding a new
one is not really an option, because the page is filled with other controls
already. So I looked into Pmw.Notebook. There are quite a few lists and
dicts which were to be changed and I wasn't successful in the first try.

However, if nobody has ever done this, I'd have to rebuild the whole page
after deleting/adding. I really hope there's an other way to go.

Kind regards
Franz GEIGER

You need to get hold of the "tab" widget and change it's text.

nb = Pmw.NoteBook(root)
nb.pack()
nb.add("Page1")
nb.add("Page2")
nb.add("Page3")
tab = nb.tab("Page1")
tab["text"]= "Martin1"


Regards

--
Martin Franklin <mf********@gatwick.westerngeco.slb.com>
Jul 18 '05 #2

P: n/a
Thank you Martin,

but I've still troubles, because the tab has the new name now, but the page
is in PMW still known with the old name.

I see this because I've registered for the raisecommand event:

def _onSelect_(self, pageName):
Proxy.DataProxy().containerSelect(pageName)
return

And here pageName is the old name despite the fact that the new name is
displayed on the tab.

Kind regards
Franz GEIGER
"Martin Franklin" <mf********@gatwick.westerngeco.slb.com> schrieb im
Newsbeitrag news:ma*********************************@python.or g...
On Tue, 2003-09-30 at 14:49, F. GEIGER wrote:
Hi again,

I'd like to rename a page of a notebook. Deleting the page and adding a new one is not really an option, because the page is filled with other controls already. So I looked into Pmw.Notebook. There are quite a few lists and
dicts which were to be changed and I wasn't successful in the first try.

However, if nobody has ever done this, I'd have to rebuild the whole page after deleting/adding. I really hope there's an other way to go.

Kind regards
Franz GEIGER

You need to get hold of the "tab" widget and change it's text.

nb = Pmw.NoteBook(root)
nb.pack()
nb.add("Page1")
nb.add("Page2")
nb.add("Page3")
tab = nb.tab("Page1")
tab["text"]= "Martin1"


Regards

--
Martin Franklin <mf********@gatwick.westerngeco.slb.com>

Jul 18 '05 #3

P: n/a
On Tue, 2003-09-30 at 17:59, F. GEIGER wrote:
Thank you Martin,

but I've still troubles, because the tab has the new name now, but the page
is in PMW still known with the old name.

I see this because I've registered for the raisecommand event:

def _onSelect_(self, pageName):
Proxy.DataProxy().containerSelect(pageName)
return

And here pageName is the old name despite the fact that the new name is
displayed on the tab.

Kind regards
Franz GEIGER
"Martin Franklin" <mf********@gatwick.westerngeco.slb.com> schrieb im
Newsbeitrag news:ma*********************************@python.or g...
On Tue, 2003-09-30 at 14:49, F. GEIGER wrote:
Hi again,

I'd like to rename a page of a notebook. Deleting the page and adding a new one is not really an option, because the page is filled with other controls already. So I looked into Pmw.Notebook. There are quite a few lists and
dicts which were to be changed and I wasn't successful in the first try.

However, if nobody has ever done this, I'd have to rebuild the whole page after deleting/adding. I really hope there's an other way to go.

Kind regards
Franz GEIGER

You need to get hold of the "tab" widget and change it's text.

nb = Pmw.NoteBook(root)
nb.pack()
nb.add("Page1")
nb.add("Page2")
nb.add("Page3")
tab = nb.tab("Page1")
tab["text"]= "Martin1"

I've been trying to 'get round' this..... without much success
internally the NoteBook keeps track of it's pages using both a list of
names and a dictionary of name : page attributes

so I thought you could mess around with these...

notebook._pageAttrs[newname] = notebook._pageAttrs[oldname]
notebook.tab(oldname)["text"]=newname
notebook._pageNames[index]=newname
del notebook._pageAttrs[oldname]

However when you try to raise your newly renamed page it fails :-(
because the callback that lifts the page to the top has the page name
stuck in it like so:

if self._withTabs:
# Create the button for the tab.
def raiseThisPage(self = self, pageName = pageName):
self.selectpage(pageName)
tabOptions['command'] = raiseThisPage
Where pageName is the name given at the time the page was created
(the above code is from the insert method in PmwNotebook)

So you would have to do quite a lot of messing around....
replacing the above callback with your own at least... This is where I
stopped trying...

So in order to keep it simple I would (in your own code) keep a
dictionary of old vs new page names or something simple like that.
So you above method would look something like this:-
def _onSelect_(self, pageName):
realPageName = self.myPageDict[pageName]
Proxy.DataProxy().containerSelect(realPageName)
return

Or failing that convert the pageName into a page index (an integer)
using the notebook.index(pageName) method.
HTH
Martin
P.S Most people on this list do not top post. (I'm not saying this is
good _or_ bad ;-)
--
Martin Franklin <mf********@gatwick.westerngeco.slb.com>
Jul 18 '05 #4

P: n/a

"Martin Franklin" <mf********@gatwick.westerngeco.slb.com> schrieb im
Newsbeitrag news:ma**********************************@python.o rg...
On Tue, 2003-09-30 at 17:59, F. GEIGER wrote:
Thank you Martin,

but I've still troubles, because the tab has the new name now, but the page is in PMW still known with the old name.

I see this because I've registered for the raisecommand event:

def _onSelect_(self, pageName):
Proxy.DataProxy().containerSelect(pageName)
return

And here pageName is the old name despite the fact that the new name is
displayed on the tab.

Kind regards
Franz GEIGER
"Martin Franklin" <mf********@gatwick.westerngeco.slb.com> schrieb im
Newsbeitrag news:ma*********************************@python.or g...
On Tue, 2003-09-30 at 14:49, F. GEIGER wrote:
> Hi again,
>
> I'd like to rename a page of a notebook. Deleting the page and adding a
new
> one is not really an option, because the page is filled with other controls
> already. So I looked into Pmw.Notebook. There are quite a few lists

and > dicts which were to be changed and I wasn't successful in the first try. >
> However, if nobody has ever done this, I'd have to rebuild the whole

page
> after deleting/adding. I really hope there's an other way to go.
>
> Kind regards
> Franz GEIGER
>
>
>
You need to get hold of the "tab" widget and change it's text.

nb = Pmw.NoteBook(root)
nb.pack()
nb.add("Page1")
nb.add("Page2")
nb.add("Page3")
tab = nb.tab("Page1")
tab["text"]= "Martin1"

I've been trying to 'get round' this..... without much success
internally the NoteBook keeps track of it's pages using both a list of
names and a dictionary of name : page attributes

so I thought you could mess around with these...

notebook._pageAttrs[newname] = notebook._pageAttrs[oldname]
notebook.tab(oldname)["text"]=newname
notebook._pageNames[index]=newname
del notebook._pageAttrs[oldname]

However when you try to raise your newly renamed page it fails :-(
because the callback that lifts the page to the top has the page name
stuck in it like so:

if self._withTabs:
# Create the button for the tab.
def raiseThisPage(self = self, pageName = pageName):
self.selectpage(pageName)
tabOptions['command'] = raiseThisPage
Where pageName is the name given at the time the page was created
(the above code is from the insert method in PmwNotebook)

So you would have to do quite a lot of messing around....
replacing the above callback with your own at least... This is where I
stopped trying...


Many thanks for your effort, Martin!

So in order to keep it simple I would (in your own code) keep a
dictionary of old vs new page names or something simple like that.
So you above method would look something like this:-
def _onSelect_(self, pageName):
realPageName = self.myPageDict[pageName]
Proxy.DataProxy().containerSelect(realPageName)
return
That's a good idea! I'll go for that.



Or failing that convert the pageName into a page index (an integer)
using the notebook.index(pageName) method.
HTH
Martin
Many thanks again and kind regards
Franz GEIGER


P.S Most people on this list do not top post. (I'm not saying this is
good _or_ bad ;-)
--
Martin Franklin <mf********@gatwick.westerngeco.slb.com>

Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.