Wrap Tk widget using a class

Fredrik Lundh fredrik at pythonware.com
Thu Jan 10 17:19:09 EST 2008


Kevin Walzer wrote:


> Here is an example of how I'm calling this in my code:
> 
> from Macnotebook import Macnotebook
> 
>          self.prefbook = Macnotebook.notebook(self.prefframe)
>          self.prefbook.pack(fill=BOTH, expand=YES, side=TOP)

you're attempting to call the method in a class object.  I suspect that 
you have to create an instance of that class first:

     self.prefbook = Macnotebook(self.prefframe)
     self.prefbook.notebook() # create it
     self.prefbook.pack(...)

     # call self.prefbook.add() to add pages to the notebook

(it's probably a good idea to move the notebook creation code into the 
__init__ method; two-stage construction isn't very pythonic...)

</F>




More information about the Python-list mailing list