title: Computer keeps restarting when trying to open py2app application
body: <p>I've made a really simple desktop app using Tkinter. When I set up everything in py2app the program looks like its generated fine, but when I click on it to open my computer restarts everytime. The code will run fine when I run it out of the Python IDE, but my screen goes black and restarts and brings me back to the MacOS login page when I try to run it by clicking on the icon or running the py2app version from the terminal. Has anyone run into this issue?</p>
  <pre><code>from tkinter import *
  import tkinter
  
  # importing everyting from tkinter
  # expression to access among all the functions
  expression = &quot;&quot;
  # functions
  def input_number(number, equation):
     # accessing the global expression variable
     global expression
     # concatenation of string
     expression = expression + str(number)
     equation.set(expression)
  def clear_input_field(equation):
     global expression
     expression = &quot;&quot;
     # setting empty string in the input field
     equation.set(&quot;Enter the expression&quot;)
  def evaluate(equation):
      global expression
      # trying to evaluate the expression
      try:
          result = str(eval(expression))
          # showing the result in the input field
          equation.set(result)
          # setting expression to empty string
          expression = &quot;&quot;
      except:
      # some error occured
      # showing it to the user equation.set(&quot;Enter a valid expression&quot;)
          expression = &quot;&quot;
  
  def new_calc():
     new_window = Tk()
     new_window.title(&quot;A whole new window&quot;)
     # set the configuration of GUI window
     new_window.geometry(&quot;450x220&quot;)
     print('This is a new window!')
  
      
  # creating the GUI
  def main():
     # main window
     window = Tk()
     # setting the title of GUI window
     window.title(&quot;Calculator&quot;)
     # set the configuration of GUI window
     window.geometry(&quot;450x220&quot;)
     # varible class instantiation
     equation = StringVar()
     # input field for the expression
     input_field = Entry(window, textvariable=equation)
     input_field.place(height=100)
     # we are using grid position
     # for the arrangement of the widgets
     input_field.grid(columnspan=4, ipadx=100, ipady=5)
     # settin the placeholder message for users
     equation.set(&quot;Enter the expression&quot;)
     # creating buttons and placing them at respective positions
     _1 = Button(window, text='1', bd=0, command=lambda: input_number(1, equation), height=2, width=7)
     _1.grid(row=2, column=0)
     _2 = Button(window, text='2', bd=0, command=lambda: input_number(2, equation), height=2, width=7)
     _2.grid(row=2, column=1)
     _3 = Button(window, text='3', bd=0, command=lambda: input_number(3, equation), height=2, width=7)
     _3.grid(row=2, column=2)
     _4 = Button(window, text='4', bd=0, command=lambda: input_number(4, equation), height=2, width=7)
     _4.grid(row=3, column=0)
     _5 = Button(window, text='5', bd=0, command=lambda: input_number(5, equation), height=2, width=7)
     _5.grid(row=3, column=1)
     _6 = Button(window, text='6', bd=0, command=lambda: input_number(6, equation), height=2, width=7)
     _6.grid(row=3, column=2)
     _7 = Button(window, text='7', bd=0, command=lambda: input_number(7, equation), height=2, width=7)
     _7.grid(row=4, column=0)
     _8 = Button(window, text='8', bd=0, command=lambda: input_number(8, equation), height=2, width=7)
     _8.grid(row=4, column=1)
     _9 = Button(window, text='9', bd=0, command=lambda: input_number(9, equation), height=2, width=7)
     _9.grid(row=4, column=2)
     _0 = Button(window, text='0', bd=0, command=lambda: input_number(0, equation), height=2, width=7)
     _0.grid(row=5, column=0)
     plus = Button(window, text='+', bd=0, command=lambda: input_number('+', equation), height=2, width=7)
     plus.grid(row=2, column=3)
     minus = Button(window, text='-',bd=0, command=lambda: input_number('-', equation), height=2, width=7)
     minus.grid(row=3, column=3)
     multiply = Button(window, text='*', bd=0, command=lambda:  input_number('*', equation), height=2, width=7)
     multiply.grid(row=4, column=3)
     divide = Button(window, text='/', bd=0, command=lambda: input_number('/', equation), height=2, width=7)
     divide.grid(row=5, column=3)
     equal = Button(window, text='=', bd=0, command=lambda: evaluate(equation), height=2, width=7)
     equal.grid(row=5, column=2)
     clear = Button(window, text='Clear', bd=0, command=lambda: clear_input_field(equation), height=2, width=7)
     clear.grid(row=5, column=1)
     # showing the GUI
     window.mainloop()
  # start of the program
  if __name__ == '__main__':
        main()
  </code></pre>
  <p>Here is the setup file:</p>
  <pre><code>from setuptools import Extension, setup
  
  APP = ['CalcApp.py']
  DATA_FILES = []
  OPTIONS = {
   'iconfile':'Calculator.icns',
   'argv_emulation': True,
   'packages': ['certifi'],
  }
  
  setup(
      app=APP,
      data_files=DATA_FILES,
      options={'py2app': OPTIONS},
      setup_requires=['py2app'],
  )
  </code></pre>