title: How do you create a streamlined gui in python using multiple function?
body: <p>I am trying to create a gui which would for example end the program once the user clicks a button, however, since the main portion of the program is located in the main() function, I cannot find a way to to end the program inside another function.
  This is my code:</p>
  <pre><code>import turtle
  import random
  from tkinter import *
  from tkinter import messagebox
  
  
  def main():
      windowScreen = Tk()
      windowScreen.title(&quot;Our cinema Application!&quot;)
      lbl = Label(windowScreen, text=&quot;Welcome to our cinema Application!&quot;,font=(&quot;Arial bold&quot;,50))
      lbl.grid(column=0,row=0)
      btn1 = Button(windowScreen, text=&quot;View Available Movie&quot;, bg=&quot;green&quot;, )
      btn1.grid(column=0,row=1)
      btn2 = Button(windowScreen, text=&quot;Purchase Tickets&quot;, bg=&quot;green&quot;, command=movie)
      btn2.grid(column=0,row=2)
      btn3 = Button(windowScreen, text=&quot;Exit the Application&quot;,  bg=&quot;red&quot;, command=action1, activebackground=&quot;white&quot;)
      btn3.grid(column=0,row=3)
      windowScreen.mainloop()
      print(&quot;Welcome to Dan &amp; Fred's Cinema!&quot;)
  
  
  def action1():
      messagebox.showinfo(&quot;Exit Application&quot;,&quot;Thank you for visiting and come again!&quot;)
      mainloop().exitonclick()
      exit()
  </code></pre>