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

Peter Milliken PeterM at resmed.com.au
Tue Sep 21 06:15:24 CEST 2004


Hi Chris,

Each notebook "page" is created using an instance of tkinter.Frame and
tkinter.Button (according to the reference page for NoteBook).

So your first problem would be that "buttons" can't be typed into - you need
to replace the Button component of each page with an EntryField -> which
changes to an grayed out entryfield (or something similar) once the user has
supplied the name. 

So (re)searching back into the class hierachy reveals that classes derived
from Pmw.MegaArchType's can have the "default" components from which they
are built "overridden" (refer to the "pyclass component option" section of
Pmw.MegaArchType). There are some "clues" here as to what you might have to
do - perhaps examine the code of NoteBook and then create a class that
inherits from NoteBook - which uses an entry widget of some form in the
construction of a new page and then either changes it to "Button" or "greys"
it out so it can't be changed after the user has supplied the name.
Certainly that is how I would proceed - inherit from NoteBook and create a
new class that offers this "feature" - you'll then have a nice re-usable
component that you could share with the rest of us :-) 

At first glance it is a non-trivial exercise i.e. more time than I have left
in my lunch hour to nut this one out :-) So goodluck with your journey.

Peter

> -----Original Message-----
> From: Chris Nethery [mailto:clnethery at juno.com]
> Sent: Tuesday, September 21, 2004 12:39 PM
> To: tkinter-discuss at python.org
> Subject: [Tkinter-discuss] String-names and the NoteBook entryfield
> 
> 
> 
> 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
> 
> 
> 
> ### imports ###
> 
> from Tkinter import *
> from Tkconstants import *
> import Pmw
> 
> ### initialization ###
> 
> root = Tk()
> root.wm_geometry("1015x705")
> Pmw.initialise(root)
> 
> 
> ### notebooks ###
> 
> class MyWidgets:
> 
>     def __init__(self, root):
> 
>         self.root = root
> 
>         Mainframe = Frame(self.root)
>         Mainframe.pack(fill='both', expand=1, padx=1, pady=1)
> 
>         self.Notebook = Pmw.NoteBook(Mainframe, 
> createcommand=self.curse_Selection)
>         self.Notebook.pack(fill='both', expand=1, padx=1, pady=1)
> 
>         self.nameEntryField = 
> Pmw.EntryField(self.Notebook.tab(""), 
> label_font=(('Verdana'), '7'), labelpos=W, labelmargin=0, 
> label_text='Stuff:')
>         self.nameEntryField.pack(fill='both', expand=1, 
> padx=1, pady=1)
>         fieldEntry = self.nameEntryField.component('entry').get()
> 
>         self.NotebookPage1 = self.Notebook.add(fieldEntry)
>         self.NotebookPage1.pack(fill='both', expand=1, padx=1, pady=1)
> 
>         self.NotebookPage1Frame = Frame(self.NotebookPage1, 
> borderwidth=2, width=975, height=650, relief=GROOVE)
>         self.NotebookPage1Frame.pack(fill='both', expand=1, 
> padx=1, pady=1)
> 
> 
>     def curse_Selection(self, notebook):
>         pass
> 
>         
> 
> if __name__=='__main__':
>     mw = MyWidgets(root)
>     root.mainloop()
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 


Warning:  Copyright ResMed.  Where the contents of this email and/or attachment includes materials prepared by ResMed, the use of those
materials is subject exclusively to the conditions of engagement between ResMed and the intended recipient.
 
This communication is confidential and may contain legally privileged information.
By the use of email over the Internet or other communication systems, ResMed is not waiving either confidentiality of, or legal
privilege in,the content of the email and of any attachments.
If the recipient of this message is not the intended addressee, please call ResMed immediately on  +61 2 9886 5000 Sydney, Australia.



More information about the Tkinter-discuss mailing list