title: Python Tkinter Check if Frame exists
body: <p>I am trying to do the following:</p>
  
  <ol>
  <li>Create a Tkinter App with a 'File' menu. </li>
  <li>The File Menu has 2 options, Add and View. </li>
  <li>The Add option adds a Frame and then adds a Label widget (Label 1) in the frame. </li>
  <li>If I then select the View option form the file menu, it should print out whether or not a Frame widget already exists.</li>
  </ol>
  
  <p>Following is my attempt at it, but I receive the error </p>
  
  <blockquote>
    <p>AttributeError: 'Test' object has no attribute 'tk'</p>
  </blockquote>
  
  <p>when I select the View option, can someone please help point out what I am missing here?</p>
  
  <pre><code>from tkinter import Tk, Menu, Label, Frame
  class Test():
      def __init__(self):
          self.gui = Tk()
          self.gui.geometry("600x400")
  
          menu = Menu(self.gui)
          new_item1 = Menu(menu)
          menu.add_cascade(label='File', menu=new_item1)
          new_item1.add_command(label='Add', command=self.addlbl)
          new_item1.add_command(label='View', command=self.viewlbl)    
  
          self.gui.config(menu=menu)
          self.gui.mainloop()
  
      def addlbl(self):
          f=Frame()
          f.pack()
          lbl1 = Label(f, text="Label 1").grid(row=0, column=0)
  
      def viewlbl(self):
          print(Frame.winfo_exists(self))      
  
  T=Test() 
  </code></pre>