Can someone please help me? I am using python 2, on mac yosemite thanks

Also this is a project by me its a private server for closed toontown online so i have permission to use this.

        defaultText = ""
        def __inject_wx(_):
            code = textbox.GetValue()
            exec(code, globals())

        def openInjector_wx():
            app = wx.App(redirect=False)
            frame = wx.Frame(None, title="Injector", size=(640, 400), style=wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX)
            panel = wx.Panel(frame)
            button = wx.Button(parent=panel, id=-1, label="Inject", size=(50, 20), pos=(295, 0))
            global textbox
            textbox = wx.TextCtrl(parent=panel, id=-1, pos=(20, 22), size=(600, 340), style=wx.TE_MULTILINE)
            frame.Bind(wx.EVT_BUTTON, __inject_wx, button)
            frame.Show()
            app.SetTopWindow(frame)
            textbox.AppendText(defaultText)
            threading.Thread(target=app.MainLoop).start()

        openInjector_wx()

here is the error

2015-09-13 12:54:20.313 Python[8827:57838] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8c06e03c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8d04c76e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8c06de1a +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x00007fff8a4348cb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
    4   Foundation                          0x00007fff8a3b657f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 156
    5   AppKit                              0x00007fff8e56ec41 -[NSApplication run] + 928
    6   libwx_osx_cocoau-3.0.0.2.0.dylib    0x000000010b59f418 _ZN14wxGUIEventLoop8OSXDoRunEv + 248
    7   libwx_osx_cocoau-3.0.0.2.0.dylib    0x000000010b46c60f _ZN13wxCFEventLoop5DoRunEv + 31
    8   libwx_osx_cocoau-3.0.0.2.0.dylib    0x000000010b3a50e1 _ZN15wxEventLoopBase3RunEv + 65
    9   libwx_osx_cocoau-3.0.0.2.0.dylib    0x000000010b36a787 _ZN16wxAppConsoleBase8MainLoopEv + 103
    10  _core_.so                           0x000000010b07d3dc _ZN7wxPyApp8MainLoopEv + 76
    11  _core_.so                           0x000000010b0c7d8f _wrap_PyApp_MainLoop + 79
    12  Python                              0x0000000105cc1180 PyEval_EvalFrameEx + 12778
    13  Python                              0x0000000105cbdd62 PyEval_EvalCodeEx + 1413
    14  Python                              0x0000000105c6230a PyFunction_SetClosure + 826
    15  Python                              0x0000000105c442ac PyObject_Call + 99
    16  Python                              0x0000000105c4f0cf PyMethod_New + 1210
    17  Python                              0x0000000105c442ac PyObject_Call + 99
    18  Python                              0x0000000105cc0c00 PyEval_EvalFrameEx + 11370
    19  Python                              0x0000000105cbdd62 PyEval_EvalCodeEx + 1413
    20  Python                              0x0000000105c6230a PyFunction_SetClosure + 826
    21  Python                              0x0000000105c442ac PyObject_Call + 99
    22  Python                              0x0000000105cc09ba PyEval_EvalFrameEx + 10788
    23  Python                              0x0000000105cbdd62 PyEval_EvalCodeEx + 1413
    24  Python                              0x0000000105c6230a PyFunction_SetClosure + 826
    25  Python                              0x0000000105c442ac PyObject_Call + 99
    26  Python                              0x0000000105c4f0cf PyMethod_New + 1210
    27  Python                              0x0000000105c442ac PyObject_Call + 99
    28  libpanda.1.9.dylib                  0x000000010656bdb6 _ZN6Thread16call_python_funcEP7_objectS1_ + 182
    29  libpanda.1.9.dylib                  0x000000010656bcec _ZN12PythonThread11thread_mainEv + 28
    30  libpanda.1.9.dylib                  0x000000010656d0bb _ZN15ThreadPosixImpl9root_funcEPv + 171
    31  libsystem_pthread.dylib             0x00007fff91d41268 _pthread_body + 131
    32  libsystem_pthread.dylib             0x00007fff91d411e5 _pthread_body + 0
    33  libsystem_pthread.dylib             0x00007fff91d3f41d thread_start + 13
)

You need to provide the context and code where you call NSUndoManager(). In any case, that error should point you in the right direction to fix this.