[Tkinter-discuss] Notebook - Bad Window Path Name

Mario St-Gelais mario.stg at videotron.ca
Sat Mar 19 16:58:16 CET 2011


Good Day All.

I am trying to get Notebook to work and the following code return
errors.  If I replace f2 with something similar to f1, it works.

Thanks.

Code is:

from tkinter import *
from tkinter import ttk

class ClientNoteBook():
    def __init__(self, root):
        self.root=root
        nb=ttk.Notebook(root)
        f1=Frame(nb)
        f2=FirstFrame(nb)
        nb.add(f1, text='info')
        nb.add(f2, text='in')
        nb.pack()
    def PlaceClientInfo(self):
        pass

class FirstFrame():
    def __init__(self,root):
        self.root=root
        self.frame=Frame(self.root)
        self.PlaceButtonCheck()
    def PlaceButtonCheck(self):
        self.btn=ttk.Button(self.root,text='Open
Child',command=self.DebugThis) self.btn.grid(column=0,row=1)
    def DebugThis(self):
        print('rrrrrr')

if __name__=='__main__':
    root = Tk()
    root.option_add('*font', ('verdana', 9, 'normal'))
    root.title("Information Client")
    display = ClientNoteBook(root)
    root.mainloop()

Error returned is:

Traceback (most recent call last):
  File "/tmp/clientnotebook.py", line 31, in <module>
    display = ClientNoteBook(root)
  File "/tmp/clientnotebook.py", line 11, in __init__
    nb.add(f2, text='in')
  File "/usr/lib/python3.2/tkinter/ttk.py", line 865, in add
    self.tk.call(self._w, "add", child, *(_format_optdict(kw)))
_tkinter.TclError: bad window path name "<__main__.FirstFrame object at
0x7f556e74dcd0>"


More information about the Tkinter-discuss mailing list