[Tkinter-discuss] Re: String-names and the NoteBook entryfield

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Wed Sep 22 09:21:09 CEST 2004

On Tue, 21 Sep 2004 02:38:54 GMT, Chris Nethery <clnethery at juno.com> wrote:

> Hello everyone.  I have an issue that is causing me many anxious  
> moments.  So, at long last, I feel I need to refer to the experts.
> I am trying to create a Pmw.NoteBook instance that the user names as  
> he/she creates it.  Specifically, I am trying to enable the user to name  
> the NoteBook instance in its own entryfield, similar to creating a new  
> Tree node in Windows Explorer or a new Windows folder or shortcut icon,  
> for example.  Secondly, I am having a hard time associating the input  
> string name with the NoteBook instance.  Unfortunately, I have gone  
> through many cycles trying to make things work, and the code has broken  
> each time, so I have included just the base code that (almost) works.   
> Any ideas on this one?
> Thanking you in advance,
> Christopher Nethery


I snipped all your code sorry but here is my first stab at the problem you  

 from Tkinter import *
import Pmw

class MegaNoteBook(Frame):
     def __init__(self, parent):

         addButton = Button(self, text="Add Page", command=self.addPage)
         self.noteBook = Pmw.NoteBook(self)
         self.noteBook.pack(fill="both", expand="yes")

     def addPage(self):
         ## method to add a page to the notebook - I need to change the  
'button' tab
         ## property of the nbotebook
         thisPage = self.noteBook.add("NewPage")
         ## find the button widget for this page bind to
         thisTab = self.noteBook.tab("NewPage")
         ##it's text put up an entry field so the user can edit it
         x, y = thisTab.winfo_rootx(), thisTab.winfo_rooty()
         entry = MegaEntryField(x, y, self)

     def setNewPageName(self, name):
         print name

class MegaEntryField(Toplevel):
     def __init__(self, topx, topy, megaNoteBook):
         self.geometry("+%d+%d" %(topx, topy))
         self.megaNoteBook = megaNoteBook
         self.entry = Pmw.EntryField(self, entry_width = 7,  
         self.entry.pack() ## ?? should size accordingly

     def renamePage(self):
         name = self.entry.get()

mnb = MegaNoteBook(root)
mnb.pack(fill="both", expand="yes")

Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

More information about the Tkinter-discuss mailing list