title: How to make a function identify another? Python
body: <p>So I have this code which create sort of like a form for users to fill on a Tkinter Canvas. In the space where they have to fill in their name, if they enter anything that is not an alphabet, I want my code to display an error message when they click the next button.
  Here is a relevant piece of the code:</p>
  <pre><code>def check():
  
  if not Name.isalpha():
      messagebox.showerror('Only letters', 'Only letters are allowed!')
  
  def Per_Form():
      canvas.delete(&quot;all&quot;)
      root.configure(bg=&quot;cornflower blue&quot;)
      canvas.config(width=root.winfo_screenwidth(), height=root.winfo_screenheight(),
                   bg=&quot;cornflower blue&quot;)  # to horizontally center the rectangle
      form_title = canvas.create_rectangle(30, 20, 700, 75, fill=&quot;white&quot;, width=2)
      canvas.move(form_title, 300, 30)
      canvas.create_text(665, 70, text=&quot;Tell us more about you..&quot;)
  
      FirstName = Label(canvas, text=&quot;First Name&quot;)
      FirstName.configure(width=30, bg=&quot;white&quot;, fg=&quot;black&quot;, border=10)
      FirstName = canvas.create_window(330, 130, anchor=NW, window=FirstName)
  FName_Entry = Entry(canvas)
      canvas.create_window(850, 145, window=FName_Entry, height=35, width=300)
      Name = FName_Entry.get()
  .
  .
  .
  .
     
  
   Next_button = Button(root, text=&quot;Next&quot;, anchor=CENTER, command=check)
      Next_button.configure(width=10, bg=&quot;black&quot;, fg=&quot;blue&quot;, border=10)
      Next_button = canvas.create_window(180, 200, anchor=NW, window=Next_button)
  </code></pre>
  <p>The code refuses to recognize the Name variable as it is in the <code>Per_Form</code> function. What do I do?</p>
  <p>I have tried several variations of this but they dont work</p>
  <p>Edit:</p>
  <pre><code>def check(Name):
      if not Name.isalpha():
          messagebox.showerror('Only letters', 'Only letters are allowed!')
      else:
          messagebox.showerror('Only letters', 'Perfect')
  
  
  def Per_Form():
      canvas.delete(&quot;all&quot;)
      root.configure(bg=&quot;cornflower blue&quot;)
      canvas.config(width=root.winfo_screenwidth(), height=root.winfo_screenheight(),
                    bg=&quot;cornflower blue&quot;)  # to horizontally center the rectangle
      form_title = canvas.create_rectangle(30, 20, 700, 75, fill=&quot;white&quot;, width=2)
      canvas.move(form_title, 300, 30)
      canvas.create_text(665, 70, text=&quot;Tell us more about you..&quot;)
  
      FirstName = Label(canvas, text=&quot;First Name&quot;)
      FirstName.configure(width=30, bg=&quot;white&quot;, fg=&quot;black&quot;, border=10)
      FirstName = canvas.create_window(330, 130, anchor=NW, window=FirstName)
  
      FName_Entry = Entry(canvas)
      canvas.create_window(850, 145, window=FName_Entry, height=35, width=300)
      Name = FName_Entry.get()
  .
  .
  .
  .
  Next_button = Button(root, text=&quot;Next&quot;, anchor=CENTER, command=lambda: check(Name))
      Next_button.configure(width=10, bg=&quot;black&quot;, fg=&quot;blue&quot;, border=10)
      Next_button = canvas.create_window(180, 200, anchor=NW, window=Next_button)
  </code></pre>