Seite 1 von 2

Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 12:22
von Hillson
Moin Leute,

ich habe mich an mein erstes "größeres" Projekt gewagt. Bisher konnte ich alle Herausforderung alleine bewältigen. Heute wollte ich das Projekt dann mit einigen kleinen weitestgehend kosmetischen Anpassungen abschließen. Irgendwie muss mir dabei aber ein Fehler unterlaufen sein.

Sobald ein Wecker aktive werden würde, bekomme ich eine Warnung, Python schließt sich und es klingelt kein Wecker.

Hier einmal mein Code:

Code: Alles auswählen

import tkinter as tk
from time import strftime, time, sleep
from playsound import playsound
from threading import Thread

alarm_database = []


def set_alarm():

    while True:

        i = 0
        for alarm, status in alarm_database:

            if (alarm == strftime("%H:%M")) and (status == "ON"):
                playsound("alarm.mp3")
                alarm_database[i] = (alarm, "OFF")

            else:
                sleep(1)
            i += 1
        update_listbox()


def save_alarm():

    new_alarm = input_widget.get()
    input_widget.delete(0, tk.END)

    if new_alarm not in alarm_database:
        alarm_database.append((new_alarm, "ON"))
        update_listbox()

        if not background_thread.is_alive():
            background_thread.start()


def update_listbox():
    main_listbox.delete(0, tk.END)
    main_listbox.insert(tk.END, *[i[0] for i in alarm_database])

    i = 0
    for _, status in alarm_database:

        if status == "ON":
            main_listbox.itemconfig(i, bg='green')

        else:
            main_listbox.itemconfig(i, bg='red')

        i += 1


def turn_on_alarm():
    index = main_listbox.curselection()

    if alarm_database[index[0]][1] == "OFF":
        main_listbox.itemconfig(index, bg='green')
        alarm_database[index[0]] = (main_listbox.get(index), "ON")
        update_listbox()

    main_listbox.select_clear(0, 'end')


def turn_off_alarm():
    index = main_listbox.curselection()

    if alarm_database[index[0]][1] == "ON":
        main_listbox.itemconfig(index, bg='red')
        alarm_database[index[0]] = (main_listbox.get(index), "OFF")
        update_listbox()

    main_listbox.select_clear(0, 'end')


def delet_alarm():
    index = main_listbox.curselection()
    del alarm_database[index[0]]
    update_listbox()


window = tk.Tk()
window.title("ALARM CLOCK")

top_frame = tk.Frame(window)
top_frame.pack()
bottom_frame = tk.Frame(window)
bottom_frame.pack(side=tk.BOTTOM)
middle_frame = tk.Frame(window)
middle_frame.pack(side=tk.BOTTOM)

tk.Label(top_frame, text="Alarm (hh:mm)").pack()
input_widget = tk.Entry(top_frame)
input_widget.pack()

button = tk.Button(top_frame, text="SAVE", command=save_alarm)
button.pack()

main_listbox = tk.Listbox(middle_frame, height=5)
main_listbox.pack()

button_1 = tk.Button(bottom_frame, text="ON", command=turn_on_alarm)
button_1.pack(side=tk.LEFT)
button_2 = tk.Button(bottom_frame, text="OFF", command=turn_off_alarm)
button_2.pack(side=tk.LEFT)
button_3 = tk.Button(bottom_frame, text="DELET", command=delet_alarm)
button_3.pack(side=tk.LEFT)

background_thread = Thread(target=set_alarm)

window.mainloop()
Hier die Warnung:

Code: Alles auswählen

2020-01-01 11:41:50.509 Python[1332:43006] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
	0   AppKit                              0x00007fff2ad54575 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 371
	1   AppKit                              0x00007fff2ad3bed5 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
	2   AppKit                              0x00007fff2ad3b947 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
	3   libtk8.6.dylib                      0x000000010f8b8a55 TkMacOSXMakeRealWindowExist + 729
	4   libtk8.6.dylib                      0x000000010f8b868a TkWmMapWindow + 56
	5   libtk8.6.dylib                      0x000000010f81b788 Tk_MapWindow + 69
	6   libtk8.6.dylib                      0x000000010f824a15 MapFrame + 59
	7   libtcl8.6.dylib                     0x000000010f768570 TclServiceIdle + 87
	8   libtcl8.6.dylib                     0x000000010f74bd27 Tcl_DoOneEvent + 349
	9   _tkinter.cpython-38-darwin.so       0x000000010f67c3de _tkinter_tkapp_mainloop + 382
	10  Python                              0x000000010efc7ace method_vectorcall_FASTCALL + 254
	11  Python                              0x000000010f08b7dc call_function + 444
	12  Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	13  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	14  Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	15  Python                              0x000000010efc159a method_vectorcall + 170
	16  Python                              0x000000010f08b7dc call_function + 444
	17  Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	18  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	19  Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	20  Python                              0x000000010f07f4b2 builtin_exec + 626
	21  Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	22  Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	23  Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	24  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	25  Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	26  Python                              0x000000010f08b7dc call_function + 444
	27  Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	28  Python                              0x000000010efbeed0 function_code_fastcall + 128
	29  Python                              0x000000010f08b7dc call_function + 444
	30  Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	31  Python                              0x000000010efbeed0 function_code_fastcall + 128
	32  Python                              0x000000010f08b7dc call_function + 444
	33  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	34  Python                              0x000000010efbeed0 function_code_fastcall + 128
	35  Python                              0x000000010f08b7dc call_function + 444
	36  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	37  Python                              0x000000010efbeed0 function_code_fastcall + 128
	38  Python                              0x000000010efc0726 object_vacall + 374
	39  Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	40  Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	41  Python                              0x000000010f07e477 builtin___import__ + 135
	42  Python                              0x000000010efbeb18 cfunction_call_varargs + 120
	43  Python                              0x000000010efbe585 _PyObject_MakeTpCall + 373
	44  Python                              0x000000010efbfc51 _PyObject_CallFunctionVa + 385
	45  Python                              0x000000010efbfaaf PyObject_CallFunction + 143
	46  Python                              0x000000010f0b7bd3 PyImport_Import + 451
	47  Python                              0x000000010f0b618f PyImport_ImportModule + 31
	48  _elementtree.cpython-38-darwin.so   0x0000000114d6eaf5 PyInit__elementtree + 181
	49  Python                              0x000000010f0b9daa _PyImport_LoadDynamicModuleWithSpec + 714
	50  Python                              0x000000010f0b956b _imp_create_dynamic + 315
	51  Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	52  Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	53  Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	54  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	55  Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	56  Python                              0x000000010f08b7dc call_function + 444
	57  Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	58  Python                              0x000000010efbeed0 function_code_fastcall + 128
	59  Python                              0x000000010f08b7dc call_function + 444
	60  Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	61  Python                              0x000000010efbeed0 function_code_fastcall + 128
	62  Python                              0x000000010f08b7dc call_function + 444
	63  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	64  Python                              0x000000010efbeed0 function_code_fastcall + 128
	65  Python                              0x000000010f08b7dc call_function + 444
	66  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	67  Python                              0x000000010efbeed0 function_code_fastcall + 128
	68  Python                              0x000000010f08b7dc call_function + 444
	69  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	70  Python                              0x000000010efbeed0 function_code_fastcall + 128
	71  Python                              0x000000010efc0726 object_vacall + 374
	72  Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	73  Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	74  Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	75  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	76  Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	77  Python                              0x000000010f07f4b2 builtin_exec + 626
	78  Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	79  Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	80  Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	81  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	82  Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	83  Python                              0x000000010f08b7dc call_function + 444
	84  Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	85  Python                              0x000000010efbeed0 function_code_fastcall + 128
	86  Python                              0x000000010f08b7dc call_function + 444
	87  Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	88  Python                              0x000000010efbeed0 function_code_fastcall + 128
	89  Python                              0x000000010f08b7dc call_function + 444
	90  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	91  Python                              0x000000010efbeed0 function_code_fastcall + 128
	92  Python                              0x000000010f08b7dc call_function + 444
	93  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	94  Python                              0x000000010efbeed0 function_code_fastcall + 128
	95  Python                              0x000000010efc0726 object_vacall + 374
	96  Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	97  Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	98  Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	99  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	100 Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	101 Python                              0x000000010f07f4b2 builtin_exec + 626
	102 Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	103 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	104 Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	105 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	106 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	107 Python                              0x000000010f08b7dc call_function + 444
	108 Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	109 Python                              0x000000010efbeed0 function_code_fastcall + 128
	110 Python                              0x000000010f08b7dc call_function + 444
	111 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	112 Python                              0x000000010efbeed0 function_code_fastcall + 128
	113 Python                              0x000000010f08b7dc call_function + 444
	114 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	115 Python                              0x000000010efbeed0 function_code_fastcall + 128
	116 Python                              0x000000010f08b7dc call_function + 444
	117 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	118 Python                              0x000000010efbeed0 function_code_fastcall + 128
	119 Python                              0x000000010efc0726 object_vacall + 374
	120 Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	121 Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	122 Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	123 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	124 Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	125 Python                              0x000000010f07f4b2 builtin_exec + 626
	126 Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	127 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	128 Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	129 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	130 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	131 Python                              0x000000010f08b7dc call_function + 444
	132 Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	133 Python                              0x000000010efbeed0 function_code_fastcall + 128
	134 Python                              0x000000010f08b7dc call_function + 444
	135 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	136 Python                              0x000000010efbeed0 function_code_fastcall + 128
	137 Python                              0x000000010f08b7dc call_function + 444
	138 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	139 Python                              0x000000010efbeed0 function_code_fastcall + 128
	140 Python                              0x000000010f08b7dc call_function + 444
	141 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	142 Python                              0x000000010efbeed0 function_code_fastcall + 128
	143 Python                              0x000000010efc0726 object_vacall + 374
	144 Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	145 Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	146 Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	147 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	148 Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	149 Python                              0x000000010f07f4b2 builtin_exec + 626
	150 Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	151 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	152 Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	153 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	154 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	155 Python                              0x000000010f08b7dc call_function + 444
	156 Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	157 Python                              0x000000010efbeed0 function_code_fastcall + 128
	158 Python                              0x000000010f08b7dc call_function + 444
	159 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	160 Python                              0x000000010efbeed0 function_code_fastcall + 128
	161 Python                              0x000000010f08b7dc call_function + 444
	162 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	163 Python                              0x000000010efbeed0 function_code_fastcall + 128
	164 Python                              0x000000010f08b7dc call_function + 444
	165 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	166 Python                              0x000000010efbeed0 function_code_fastcall + 128
	167 Python                              0x000000010efc0726 object_vacall + 374
	168 Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	169 Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	170 Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	171 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	172 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	173 Python                              0x000000010f08b7dc call_function + 444
	174 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	175 Python                              0x000000010efbeed0 function_code_fastcall + 128
	176 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	177 Python                              0x000000010f088af8 _PyEval_EvalFrameDefault + 26968
	178 Python                              0x000000010efbeed0 function_code_fastcall + 128
	179 Python                              0x000000010f08b7dc call_function + 444
	180 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	181 Python                              0x000000010efbeed0 function_code_fastcall + 128
	182 Python                              0x000000010f08b7dc call_function + 444
	183 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	184 Python                              0x000000010efbeed0 function_code_fastcall + 128
	185 Python                              0x000000010efc15db method_vectorcall + 235
	186 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	187 Python                              0x000000010f12a9fa t_bootstrap + 74
	188 Python                              0x000000010f0de2c9 pythread_wrapper + 25
	189 libsystem_pthread.dylib             0x00007fff653bee65 _pthread_start + 148
	190 libsystem_pthread.dylib             0x00007fff653ba83b thread_start + 15
)
2020-01-01 11:41:50.519 Python[1332:43006] *** Assertion failure in void assertRunningOnAppKitThread(void)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/ViewBridge/ViewBridge-462/ViewBridgeUtilities.m:900
2020-01-01 11:41:50.526 Python[1332:43006] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'not running on AppKit (main) thread'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff2dbdb8ab __exceptionPreprocess + 250
	1   libobjc.A.dylib                     0x00007fff63e4c805 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff2dc04d10 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff3033bad7 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
	4   ViewBridge                          0x00007fff604b76c4 -[NSRemoteView _preSuperInit] + 25
	5   ViewBridge                          0x00007fff604b7653 -[NSRemoteView initWithFrame:] + 25
	6   ViewBridge                          0x00007fff604b7404 +[NSRemoteViewController requestViewController:withServiceViewControllerIdentifier:connectionHandler:withBlock:] + 193
	7   ViewBridge                          0x00007fff605479de +[NSRemoteViewController requestViewController:fromServiceListenerEndpoint:connectionHandler:] + 228
	8   HIToolbox                           0x00007fff2c9111bb -[IMKInputSession presentFunctionRowItemTextInputViewWithEndpoint:completionHandler:] + 1555
	9   HIToolbox                           0x00007fff2c9005a4 __80-[IMKInputSession imkxpc_presentFunctionRowItemTextInputViewWithEndpoint:reply:]_block_invoke + 556
	10  CoreFoundation                      0x00007fff2db5f7ab __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	11  CoreFoundation                      0x00007fff2db5f6ed __CFRunLoopDoBlocks + 379
	12  CoreFoundation                      0x00007fff2db5ed30 __CFRunLoopRun + 2792
	13  CoreFoundation                      0x00007fff2db5dbd3 CFRunLoopRunSpecific + 499
	14  HIToolbox                           0x00007fff2c6facbd -[IMKInputSessionXPCInvocation invocationAwaitXPCReply] + 477
	15  HIToolbox                           0x00007fff2c6f4e5a -[IMKInputSession activate] + 3546
	16  HIToolbox                           0x00007fff2c6f4073 IMKInputSessionActivate + 36
	17  HIToolbox                           0x00007fff2c6f403f ActivateInputMethodInstance + 93
	18  HIToolbox                           0x00007fff2c6f2b40 utOpenActivateSelectedInputMethodInDoc + 355
	19  HIToolbox                           0x00007fff2c6f29cd utOpenActivateAllSelectedIMInDocIterator + 21
	20  CoreFoundation                      0x00007fff2db210db CFArrayApplyFunction + 62
	21  HIToolbox                           0x00007fff2c6d220b utOpenActivateAllSelectedIMInDoc + 178
	22  HIToolbox                           0x00007fff2c6c96c7 MyActivateTSMDocument + 1793
	23  AppKit                              0x00007fff2af550c8 -[NSTextInputContext activate] + 323
	24  AppKit                              0x00007fff2ad2aca2 +[NSTextInputContext currentInputContext_withFirstResponderSync:] + 343
	25  AppKit                              0x00007fff2aec7cf8 +[_NSAutomaticFocusRing setActiveFirstResponderChanged] + 34
	26  AppKit                              0x00007fff2b5b9fea ___NSPostActiveFirstResponderChanged_block_invoke.llvm.835525990940153882 + 29
	27  AppKit                              0x00007fff2b5c95db ___NSRunLoopObserverCreateWithHandler_block_invoke.llvm.835525990940153882 + 41
	28  CoreFoundation                      0x00007fff2db5f0ee __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	29  CoreFoundation                      0x00007fff2db5f014 __CFRunLoopDoObservers + 457
	30  CoreFoundation                      0x00007fff2db5e70b __CFRunLoopRun + 1219
	31  CoreFoundation                      0x00007fff2db5dbd3 CFRunLoopRunSpecific + 499
	32  libtcl8.6.dylib                     0x000000010f795708 Tcl_WaitForEvent + 267
	33  libtcl8.6.dylib                     0x000000010f74bcdb Tcl_DoOneEvent + 273
	34  _tkinter.cpython-38-darwin.so       0x000000010f67c3de _tkinter_tkapp_mainloop + 382
	35  Python                              0x000000010efc7ace method_vectorcall_FASTCALL + 254
	36  Python                              0x000000010f08b7dc call_function + 444
	37  Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	38  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	39  Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	40  Python                              0x000000010efc159a method_vectorcall + 170
	41  Python                              0x000000010f08b7dc call_function + 444
	42  Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	43  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	44  Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	45  Python                              0x000000010f07f4b2 builtin_exec + 626
	46  Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	47  Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	48  Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	49  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	50  Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	51  Python                              0x000000010f08b7dc call_function + 444
	52  Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	53  Python                              0x000000010efbeed0 function_code_fastcall + 128
	54  Python                              0x000000010f08b7dc call_function + 444
	55  Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	56  Python                              0x000000010efbeed0 function_code_fastcall + 128
	57  Python                              0x000000010f08b7dc call_function + 444
	58  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	59  Python                              0x000000010efbeed0 function_code_fastcall + 128
	60  Python                              0x000000010f08b7dc call_function + 444
	61  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	62  Python                              0x000000010efbeed0 function_code_fastcall + 128
	63  Python                              0x000000010efc0726 object_vacall + 374
	64  Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	65  Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	66  Python                              0x000000010f07e477 builtin___import__ + 135
	67  Python                              0x000000010efbeb18 cfunction_call_varargs + 120
	68  Python                              0x000000010efbe585 _PyObject_MakeTpCall + 373
	69  Python                              0x000000010efbfc51 _PyObject_CallFunctionVa + 385
	70  Python                              0x000000010efbfaaf PyObject_CallFunction + 143
	71  Python                              0x000000010f0b7bd3 PyImport_Import + 451
	72  Python                              0x000000010f0b618f PyImport_ImportModule + 31
	73  _elementtree.cpython-38-darwin.so   0x0000000114d6eaf5 PyInit__elementtree + 181
	74  Python                              0x000000010f0b9daa _PyImport_LoadDynamicModuleWithSpec + 714
	75  Python                              0x000000010f0b956b _imp_create_dynamic + 315
	76  Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	77  Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	78  Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	79  Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	80  Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	81  Python                              0x000000010f08b7dc call_function + 444
	82  Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	83  Python                              0x000000010efbeed0 function_code_fastcall + 128
	84  Python                              0x000000010f08b7dc call_function + 444
	85  Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	86  Python                              0x000000010efbeed0 function_code_fastcall + 128
	87  Python                              0x000000010f08b7dc call_function + 444
	88  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	89  Python                              0x000000010efbeed0 function_code_fastcall + 128
	90  Python                              0x000000010f08b7dc call_function + 444
	91  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	92  Python                              0x000000010efbeed0 function_code_fastcall + 128
	93  Python                              0x000000010f08b7dc call_function + 444
	94  Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	95  Python                              0x000000010efbeed0 function_code_fastcall + 128
	96  Python                              0x000000010efc0726 object_vacall + 374
	97  Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	98  Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	99  Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	100 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	101 Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	102 Python                              0x000000010f07f4b2 builtin_exec + 626
	103 Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	104 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	105 Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	106 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	107 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	108 Python                              0x000000010f08b7dc call_function + 444
	109 Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	110 Python                              0x000000010efbeed0 function_code_fastcall + 128
	111 Python                              0x000000010f08b7dc call_function + 444
	112 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	113 Python                              0x000000010efbeed0 function_code_fastcall + 128
	114 Python                              0x000000010f08b7dc call_function + 444
	115 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	116 Python                              0x000000010efbeed0 function_code_fastcall + 128
	117 Python                              0x000000010f08b7dc call_function + 444
	118 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	119 Python                              0x000000010efbeed0 function_code_fastcall + 128
	120 Python                              0x000000010efc0726 object_vacall + 374
	121 Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	122 Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	123 Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	124 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	125 Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	126 Python                              0x000000010f07f4b2 builtin_exec + 626
	127 Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	128 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	129 Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	130 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	131 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	132 Python                              0x000000010f08b7dc call_function + 444
	133 Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	134 Python                              0x000000010efbeed0 function_code_fastcall + 128
	135 Python                              0x000000010f08b7dc call_function + 444
	136 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	137 Python                              0x000000010efbeed0 function_code_fastcall + 128
	138 Python                              0x000000010f08b7dc call_function + 444
	139 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	140 Python                              0x000000010efbeed0 function_code_fastcall + 128
	141 Python                              0x000000010f08b7dc call_function + 444
	142 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	143 Python                              0x000000010efbeed0 function_code_fastcall + 128
	144 Python                              0x000000010efc0726 object_vacall + 374
	145 Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	146 Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	147 Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	148 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	149 Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	150 Python                              0x000000010f07f4b2 builtin_exec + 626
	151 Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	152 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	153 Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	154 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	155 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	156 Python                              0x000000010f08b7dc call_function + 444
	157 Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	158 Python                              0x000000010efbeed0 function_code_fastcall + 128
	159 Python                              0x000000010f08b7dc call_function + 444
	160 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	161 Python                              0x000000010efbeed0 function_code_fastcall + 128
	162 Python                              0x000000010f08b7dc call_function + 444
	163 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	164 Python                              0x000000010efbeed0 function_code_fastcall + 128
	165 Python                              0x000000010f08b7dc call_function + 444
	166 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	167 Python                              0x000000010efbeed0 function_code_fastcall + 128
	168 Python                              0x000000010efc0726 object_vacall + 374
	169 Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	170 Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	171 Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	172 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	173 Python                              0x000000010f0820c4 PyEval_EvalCode + 100
	174 Python                              0x000000010f07f4b2 builtin_exec + 626
	175 Python                              0x000000010effa81f cfunction_vectorcall_FASTCALL + 175
	176 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	177 Python                              0x000000010f088c6b _PyEval_EvalFrameDefault + 27339
	178 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	179 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	180 Python                              0x000000010f08b7dc call_function + 444
	181 Python                              0x000000010f0885ed _PyEval_EvalFrameDefault + 25677
	182 Python                              0x000000010efbeed0 function_code_fastcall + 128
	183 Python                              0x000000010f08b7dc call_function + 444
	184 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	185 Python                              0x000000010efbeed0 function_code_fastcall + 128
	186 Python                              0x000000010f08b7dc call_function + 444
	187 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	188 Python                              0x000000010efbeed0 function_code_fastcall + 128
	189 Python                              0x000000010f08b7dc call_function + 444
	190 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	191 Python                              0x000000010efbeed0 function_code_fastcall + 128
	192 Python                              0x000000010efc0726 object_vacall + 374
	193 Python                              0x000000010efc088b _PyObject_CallMethodIdObjArgs + 235
	194 Python                              0x000000010f0b837c PyImport_ImportModuleLevelObject + 1740
	195 Python                              0x000000010f086efe _PyEval_EvalFrameDefault + 19806
	196 Python                              0x000000010f08c624 _PyEval_EvalCodeWithName + 2804
	197 Python                              0x000000010efbf06e _PyFunction_Vectorcall + 270
	198 Python                              0x000000010f08b7dc call_function + 444
	199 Python                              0x000000010f08867a _PyEval_EvalFrameDefault + 25818
	200 Python                              0x000000010efbeed0 function_code_fastcall + 128
	201 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	202 Python                              0x000000010f088af8 _PyEval_EvalFrameDefault + 26968
	203 Python                              0x000000010efbeed0 function_code_fastcall + 128
	204 Python                              0x000000010f08b7dc call_function + 444
	205 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	206 Python                              0x000000010efbeed0 function_code_fastcall + 128
	207 Python                              0x000000010f08b7dc call_function + 444
	208 Python                              0x000000010f0885c9 _PyEval_EvalFrameDefault + 25641
	209 Python                              0x000000010efbeed0 function_code_fastcall + 128
	210 Python                              0x000000010efc15db method_vectorcall + 235
	211 Python                              0x000000010efbe8ad PyVectorcall_Call + 109
	212 Python                              0x000000010f12a9fa t_bootstrap + 74
	213 Python                              0x000000010f0de2c9 pythread_wrapper + 25
	214 libsystem_pthread.dylib             0x00007fff653bee65 _pthread_start + 148
	215 libsystem_pthread.dylib             0x00007fff653ba83b thread_start + 15
)
libc++abi.dylib: terminating with uncaught exception of type NSException

[Done] exited with code=null in 10.314 seconds

[Running] python3 "/Users/tobias/Documents/Privat/Programmieren/The_Complete_Python_Course_Teachable_Discover_Edition/alarm_clock/copy.py"
2020-01-01 11:58:07.992 Python[1365:49897] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
	0   AppKit                              0x00007fff2ad54575 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 371
	1   AppKit                              0x00007fff2ad3bed5 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
	2   AppKit                              0x00007fff2ad3b947 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
	3   libtk8.6.dylib                      0x000000010ce5ba55 TkMacOSXMakeRealWindowExist + 729
	4   libtk8.6.dylib                      0x000000010ce5b68a TkWmMapWindow + 56
	5   libtk8.6.dylib                      0x000000010cdbe788 Tk_MapWindow + 69
	6   libtk8.6.dylib                      0x000000010cdc7a15 MapFrame + 59
	7   libtcl8.6.dylib                     0x000000010cd0b570 TclServiceIdle + 87
	8   libtcl8.6.dylib                     0x000000010cceed27 Tcl_DoOneEvent + 349
	9   _tkinter.cpython-38-darwin.so       0x000000010cc1f3de _tkinter_tkapp_mainloop + 382
	10  Python                              0x000000010c56aace method_vectorcall_FASTCALL + 254
	11  Python                              0x000000010c62e7dc call_function + 444
	12  Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	13  Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	14  Python                              0x000000010c56206e _PyFunction_Vectorcall + 270
	15  Python                              0x000000010c56459a method_vectorcall + 170
	16  Python                              0x000000010c62e7dc call_function + 444
	17  Python                              0x000000010c62b5ed _PyEval_EvalFrameDefault + 25677
	18  Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	19  Python                              0x000000010c6250c4 PyEval_EvalCode + 100
	20  Python                              0x000000010c6224b2 builtin_exec + 626
	21  Python                              0x000000010c59d81f cfunction_vectorcall_FASTCALL + 175
	22  Python                              0x000000010c5618ad PyVectorcall_Call + 109
	23  Python                              0x000000010c62bc6b _PyEval_EvalFrameDefault + 27339
	24  Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	25  Python                              0x000000010c56206e _PyFunction_Vectorcall + 270
	26  Python                              0x000000010c62e7dc call_function + 444
	27  Python                              0x000000010c62b5ed _PyEval_EvalFrameDefault + 25677
	28  Python                              0x000000010c561ed0 function_code_fastcall + 128
	29  Python                              0x000000010c62e7dc call_function + 444
	30  Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	31  Python                              0x000000010c561ed0 function_code_fastcall + 128
	32  Python                              0x000000010c62e7dc call_function + 444
	33  Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	34  Python                              0x000000010c561ed0 function_code_fastcall + 128
	35  Python                              0x000000010c62e7dc call_function + 444
	36  Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	37  Python                              0x000000010c561ed0 function_code_fastcall + 128
	38  Python                              0x000000010c563726 object_vacall + 374
	39  Python                              0x000000010c56388b _PyObject_CallMethodIdObjArgs + 235
	40  Python                              0x000000010c65b37c PyImport_ImportModuleLevelObject + 1740
	41  Python                              0x000000010c621477 builtin___import__ + 135
	42  Python                              0x000000010c561b18 cfunction_call_varargs + 120
	43  Python                              0x000000010c561585 _PyObject_MakeTpCall + 373
	44  Python                              0x000000010c562c51 _PyObject_CallFunctionVa + 385
	45  Python                              0x000000010c562aaf PyObject_CallFunction + 143
	46  Python                              0x000000010c65abd3 PyImport_Import + 451
	47  Python                              0x000000010c65918f PyImport_ImportModule + 31
	48  _elementtree.cpython-38-darwin.so   0x000000011230caf5 PyInit__elementtree + 181
	49  Python                              0x000000010c65cdaa _PyImport_LoadDynamicModuleWithSpec + 714
	50  Python                              0x000000010c65c56b _imp_create_dynamic + 315
	51  Python                              0x000000010c59d81f cfunction_vectorcall_FASTCALL + 175
	52  Python                              0x000000010c5618ad PyVectorcall_Call + 109
	53  Python                              0x000000010c62bc6b _PyEval_EvalFrameDefault + 27339
	54  Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	55  Python                              0x000000010c56206e _PyFunction_Vectorcall + 270
	56  Python                              0x000000010c62e7dc call_function + 444
	57  Python                              0x000000010c62b5ed _PyEval_EvalFrameDefault + 25677
	58  Python                              0x000000010c561ed0 function_code_fastcall + 128
	59  Python                              0x000000010c62e7dc call_function + 444
	60  Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	61  Python                              0x000000010c561ed0 function_code_fastcall + 128
	62  Python                              0x000000010c62e7dc call_function + 444
	63  Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	64  Python                              0x000000010c561ed0 function_code_fastcall + 128
	65  Python                              0x000000010c62e7dc call_function + 444
	66  Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	67  Python                              0x000000010c561ed0 function_code_fastcall + 128
	68  Python                              0x000000010c62e7dc call_function + 444
	69  Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	70  Python                              0x000000010c561ed0 function_code_fastcall + 128
	71  Python                              0x000000010c563726 object_vacall + 374
	72  Python                              0x000000010c56388b _PyObject_CallMethodIdObjArgs + 235
	73  Python                              0x000000010c65b37c PyImport_ImportModuleLevelObject + 1740
	74  Python                              0x000000010c629efe _PyEval_EvalFrameDefault + 19806
	75  Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	76  Python                              0x000000010c6250c4 PyEval_EvalCode + 100
	77  Python                              0x000000010c6224b2 builtin_exec + 626
	78  Python                              0x000000010c59d81f cfunction_vectorcall_FASTCALL + 175
	79  Python                              0x000000010c5618ad PyVectorcall_Call + 109
	80  Python                              0x000000010c62bc6b _PyEval_EvalFrameDefault + 27339
	81  Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	82  Python                              0x000000010c56206e _PyFunction_Vectorcall + 270
	83  Python                              0x000000010c62e7dc call_function + 444
	84  Python                              0x000000010c62b5ed _PyEval_EvalFrameDefault + 25677
	85  Python                              0x000000010c561ed0 function_code_fastcall + 128
	86  Python                              0x000000010c62e7dc call_function + 444
	87  Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	88  Python                              0x000000010c561ed0 function_code_fastcall + 128
	89  Python                              0x000000010c62e7dc call_function + 444
	90  Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	91  Python                              0x000000010c561ed0 function_code_fastcall + 128
	92  Python                              0x000000010c62e7dc call_function + 444
	93  Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	94  Python                              0x000000010c561ed0 function_code_fastcall + 128
	95  Python                              0x000000010c563726 object_vacall + 374
	96  Python                              0x000000010c56388b _PyObject_CallMethodIdObjArgs + 235
	97  Python                              0x000000010c65b37c PyImport_ImportModuleLevelObject + 1740
	98  Python                              0x000000010c629efe _PyEval_EvalFrameDefault + 19806
	99  Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	100 Python                              0x000000010c6250c4 PyEval_EvalCode + 100
	101 Python                              0x000000010c6224b2 builtin_exec + 626
	102 Python                              0x000000010c59d81f cfunction_vectorcall_FASTCALL + 175
	103 Python                              0x000000010c5618ad PyVectorcall_Call + 109
	104 Python                              0x000000010c62bc6b _PyEval_EvalFrameDefault + 27339
	105 Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	106 Python                              0x000000010c56206e _PyFunction_Vectorcall + 270
	107 Python                              0x000000010c62e7dc call_function + 444
	108 Python                              0x000000010c62b5ed _PyEval_EvalFrameDefault + 25677
	109 Python                              0x000000010c561ed0 function_code_fastcall + 128
	110 Python                              0x000000010c62e7dc call_function + 444
	111 Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	112 Python                              0x000000010c561ed0 function_code_fastcall + 128
	113 Python                              0x000000010c62e7dc call_function + 444
	114 Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	115 Python                              0x000000010c561ed0 function_code_fastcall + 128
	116 Python                              0x000000010c62e7dc call_function + 444
	117 Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	118 Python                              0x000000010c561ed0 function_code_fastcall + 128
	119 Python                              0x000000010c563726 object_vacall + 374
	120 Python                              0x000000010c56388b _PyObject_CallMethodIdObjArgs + 235
	121 Python                              0x000000010c65b37c PyImport_ImportModuleLevelObject + 1740
	122 Python                              0x000000010c629efe _PyEval_EvalFrameDefault + 19806
	123 Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	124 Python                              0x000000010c6250c4 PyEval_EvalCode + 100
	125 Python                              0x000000010c6224b2 builtin_exec + 626
	126 Python                              0x000000010c59d81f cfunction_vectorcall_FASTCALL + 175
	127 Python                              0x000000010c5618ad PyVectorcall_Call + 109
	128 Python                              0x000000010c62bc6b _PyEval_EvalFrameDefault + 27339
	129 Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	130 Python                              0x000000010c56206e _PyFunction_Vectorcall + 270
	131 Python                              0x000000010c62e7dc call_function + 444
	132 Python                              0x000000010c62b5ed _PyEval_EvalFrameDefault + 25677
	133 Python                              0x000000010c561ed0 function_code_fastcall + 128
	134 Python                              0x000000010c62e7dc call_function + 444
	135 Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	136 Python                              0x000000010c561ed0 function_code_fastcall + 128
	137 Python                              0x000000010c62e7dc call_function + 444
	138 Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	139 Python                              0x000000010c561ed0 function_code_fastcall + 128
	140 Python                              0x000000010c62e7dc call_function + 444
	141 Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	142 Python                              0x000000010c561ed0 function_code_fastcall + 128
	143 Python                              0x000000010c563726 object_vacall + 374
	144 Python                              0x000000010c56388b _PyObject_CallMethodIdObjArgs + 235
	145 Python                              0x000000010c65b37c PyImport_ImportModuleLevelObject + 1740
	146 Python                              0x000000010c629efe _PyEval_EvalFrameDefault + 19806
	147 Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	148 Python                              0x000000010c6250c4 PyEval_EvalCode + 100
	149 Python                              0x000000010c6224b2 builtin_exec + 626
	150 Python                              0x000000010c59d81f cfunction_vectorcall_FASTCALL + 175
	151 Python                              0x000000010c5618ad PyVectorcall_Call + 109
	152 Python                              0x000000010c62bc6b _PyEval_EvalFrameDefault + 27339
	153 Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	154 Python                              0x000000010c56206e _PyFunction_Vectorcall + 270
	155 Python                              0x000000010c62e7dc call_function + 444
	156 Python                              0x000000010c62b5ed _PyEval_EvalFrameDefault + 25677
	157 Python                              0x000000010c561ed0 function_code_fastcall + 128
	158 Python                              0x000000010c62e7dc call_function + 444
	159 Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	160 Python                              0x000000010c561ed0 function_code_fastcall + 128
	161 Python                              0x000000010c62e7dc call_function + 444
	162 Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	163 Python                              0x000000010c561ed0 function_code_fastcall + 128
	164 Python                              0x000000010c62e7dc call_function + 444
	165 Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	166 Python                              0x000000010c561ed0 function_code_fastcall + 128
	167 Python                              0x000000010c563726 object_vacall + 374
	168 Python                              0x000000010c56388b _PyObject_CallMethodIdObjArgs + 235
	169 Python                              0x000000010c65b37c PyImport_ImportModuleLevelObject + 1740
	170 Python                              0x000000010c629efe _PyEval_EvalFrameDefault + 19806
	171 Python                              0x000000010c62f624 _PyEval_EvalCodeWithName + 2804
	172 Python                              0x000000010c56206e _PyFunction_Vectorcall + 270
	173 Python                              0x000000010c62e7dc call_function + 444
	174 Python                              0x000000010c62b67a _PyEval_EvalFrameDefault + 25818
	175 Python                              0x000000010c561ed0 function_code_fastcall + 128
	176 Python                              0x000000010c5618ad PyVectorcall_Call + 109
	177 Python                              0x000000010c62baf8 _PyEval_EvalFrameDefault + 26968
	178 Python                              0x000000010c561ed0 function_code_fastcall + 128
	179 Python                              0x000000010c62e7dc call_function + 444
	180 Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	181 Python                              0x000000010c561ed0 function_code_fastcall + 128
	182 Python                              0x000000010c62e7dc call_function + 444
	183 Python                              0x000000010c62b5c9 _PyEval_EvalFrameDefault + 25641
	184 Python                              0x000000010c561ed0 function_code_fastcall + 128
	185 Python                              0x000000010c5645db method_vectorcall + 235
	186 Python                              0x000000010c5618ad PyVectorcall_Call + 109
	187 Python                              0x000000010c6cd9fa t_bootstrap + 74
	188 Python                              0x000000010c6812c9 pythread_wrapper + 25
	189 libsystem_pthread.dylib             0x00007fff653bee65 _pthread_start + 148
	190 libsystem_pthread.dylib             0x00007fff653ba83b thread_start + 15
)

[Done] exited with code=null in 10.458 seconds

Ich könnte mir vorstellen das es irgendwas mit dem

Code: Alles auswählen

background_thread
zutun hat, obwohl ich hier aber eigentlich keine entscheidenen Änderungen mehr gemacht habe.

Vielleicht kann mir hier jemand helfen. Ich kann mit der Warnung nichts anfangen. Über sonstige Ratschläge und Verbesserungsvorschläge bezüglich des Codes wäre ich auch sehr dankbar.

Danke.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 12:53
von Sirius3
Endlich mal ein Beispiel wo das lang gepredigte "in einem Thread darf man die GUI nicht ändern" tatsächlich reproduzierbar einem auf die Nase fällt.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 13:55
von __deets__
@Sirius3: Genau mein erster Gedanke! Endlich was zum verlinken um das Problem zu illustrieren.

@Hillson: keine Threads verwenden. Vor allem nicht für sowas triviales, wo eh nur gewartet wird. Benutz einen Timer, in tkinter mit der after-Methode umzusetzen. Gibt’s hier ne Meeeeeenge Diskussionen zu. Einfach mal etwas stöbern.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 14:13
von Hillson
@Sirius3 und @ __deets__: Danke für die Hinweise. Ich versuche das gleich mal auszubessern.

Ich konnte mit der Warnung echt nichts anfangen, deswegen wusste ich auch nicht wonach ich suchen soll bei der Fehlerbehebung. Tut mir leid fall es eine überflüssige Frage war.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 14:27
von Sirius3
Das Problem mit „alle Herausforderungen alleine bewältigen" ist, dass man erst sehr spät Rückmeldung bekommt.
Benutze keine globalen Variablen, alles was eine Funktion braucht, muß sie auch über ihre Argumente bekommen. Das ist vor allem bei GUI-Programmen irgendwann sehr viel und dann kommt man um die Definition von Klassen nicht drumrum.
Alles ab Zeile 83 gehört in eine Funktion, die man üblicherweise `main` nennt. Dann kommt man auch gar nicht erst in Verlegenheit exzessiv globale Variablen zu benutzen.

`alarm_database` ist eine Liste von Tupeln. Wenn man aber jetzt sich ändernde Objekte hat, wie Alarm on/off, dann ist ein Tuple die falsche Datenstruktur. Hier braucht man schon fast eine eigene Klasse. Oder Du benutzt die Listbox als Datenspeicher.
Apropos, `update_listbox` wird an vielen Stellen aufgerufen, und erzeugt den Inhalt jedesmal komplett neu, obwohl sich nur eine Farbe ändert.
`turn_on_alarm` und `turn_off_alarm` tun fast das selbe, und sollten daher nur eine Funktion sein.

Wenn man zusätzlich zum Inhalt einer Liste auch noch einen Zähler braucht, dann gibt es dafür `enumerate`.

Und dann ist da halt noch der Thread, der nicht sein sollte und statt dessen eine Methode, die per `after` aufgerufen wird.

Die Leerzeilensetzung, vor allem in `set_alarm` macht den Code schwer lesbar.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 14:50
von Hillson
Und ich war so froh, dass ich alles erstmal alleine hinbekommen habe ohne jemanden nach Hilfe fragen zu müssen.

Ich verstehe deinen Punkt mit der späten Rückmeldung. Mir stellt sich dann die Frage: Wann man dann am besten nach Hilfe fragen sollte? Ich will ja auch nicht ständig nerven.

Vielen Dank aber auf jeden Fall schon einmal für das ausführliche Feedback von dir!

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 16:09
von __deets__
Ich finde den Zeitpunkt jetzt nicht so dramatisch. Den natürlichen Punkt hast du ja selbst gefunden - wenn der Code kracht. Ansonsten ist das ein auch bei uns Profis ungelöstes Problem. Startet man gleich mit pair programming oder erst machen & dann im codereview “ärgern”? Wird regelmäßig mal so mal so gehandhabt, und man kommt zum Schluss, es anders gemacht zu haben wäre besser gewesen.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 23:04
von Hillson
@Sirius3: Ich habe jetzt schon einige von deinen Vorschlägen versucht umzusetzen.

Von der Funktion ist der Wecker aber noch nicht so weit wie vorher. Ich versuche gerade die timer Funktion immer wieder aufzurufen nachdem sie einmal aufgerufen wurde. Leider bekomme ich das absolut nicht hin mit der after() Methode. Zuletzt hatte ich versucht window.after(1000, timer(database)) nach der For-Schleife in timer. Aber das hat auch nicht so recht geklappt. Kannst du mir vielleicht einen Hinweis geben?

Code: Alles auswählen

import tkinter as tk
from playsound import playsound
from time import strftime, sleep


class alarm_database:
    def __init__(self):
        self.database = []

    def add_alarm(self, alarm):
        self.database.append(alarm)

    def delete_alarm(self, alarm):
        if alarm in self.database:
            self.database.remove(alarm)
        else:
            print('Alarm not in Database saved!')


class alarm:
    def __init__(self, alarm, state):
        self.alarm = alarm
        self.state = state

    def change_state(self, state):
        self.state = state


def save(input, database, main_listbox):
    new_alarm = alarm(input, True)
    database.add_alarm(new_alarm)
    main_listbox.delete(0, tk.END)
    main_listbox.insert(tk.END, *[i.alarm for i in database.database])
    timer(database)


def timer(database):

    for i in database.database:
        if i.state and i.alarm == strftime("%H:%M"):
            playsound("alarm.mp3")
            i.state = False


window = tk.Tk()
window.title("ALARM CLOCK")
database = alarm_database()


def main():
    top_frame = tk.Frame(window)
    top_frame.pack()
    bottom_frame = tk.Frame(window)
    bottom_frame.pack(side=tk.BOTTOM)
    middle_frame = tk.Frame(window)
    middle_frame.pack(side=tk.BOTTOM)

    tk.Label(top_frame, text="Alarm (hh:mm)").pack()
    input_widget = tk.Entry(top_frame)
    input_widget.pack()

    button = tk.Button(window, text="Save", command=lambda: save(
        input_widget.get(), database, main_listbox))
    button.pack()

    main_listbox = tk.Listbox(middle_frame, height=5)
    main_listbox.pack()


main()

window.mainloop()

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Mittwoch 1. Januar 2020, 23:27
von Sirius3
Klassen werden nach Konvention mit großem Anfangsbuchstaben geschrieben. Die Klasse alarm_database macht nicht mehr, als eine Liste. Ist also unnötig. i ist ein äußerst schlechter Name für einen Alarm. Seile generell allen Einbuchstabigen Variablennamen schlecht sind.
window und database gehören auch in main.
after erwartet als zweites Argument eine Funktion, alle weiteren Argumente sind die Parameter der Funktion.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 13:12
von Hillson
Die after() Methode habe ich glaube ich jetzt richtig hinbekommen und auch an der richtigen Stelle platziert. Auf jeden Fall komisch die Parameter nach der Funktion mit zugeben aber hätte man auch drauf kommen können wenn man die Dokumentation richtig ließt. Der Wecker funktioniert soweit als, dass man Alarme setzten kann und diese auch klingeln wenn die Zeit ran ist.

Nun wollte ich die Funktionen Wecker ON/OFF wieder einbauen. Allerdings kommt er irgendwie nicht in die Funktion change_state() wenn einer der beiden Buttons gedrückt wird.

Code: Alles auswählen

import tkinter as tk
from playsound import playsound
from time import strftime, sleep


class Alarm:
    def __init__(self, time, state):
        self.time = time
        self.state = state

    def change_state(self, state):
        self.state = state


def save(input_widget, database, main_listbox, window):
    alarm_time = input_widget.get()
    new_alarm = Alarm(alarm_time, True)
    input_widget.delete(0, tk.END)
    database.append(new_alarm)

    listbox_database = main_listbox.get(0, tk.END)

    if alarm_time not in listbox_database:
        main_listbox.insert(tk.END, alarm_time)
        new_listbox_database = main_listbox.get(0, tk.END)
        index = new_listbox_database.index(alarm_time)
        main_listbox.itemconfig(index, bg='green')

    #timer(database, window)


def timer(database, window):

    for alarm in database:
        if alarm.state and alarm.time == strftime("%H:%M"):
            playsound("alarm.mp3")
            alarm.state = False
    window.after(500, timer, database, window)


def change_state(main_listbox, database):

    if database:
        listbox_selection = main_listbox.curselection()
        selected_alarm_index = listbox_selection[0]
        selected_timer = main_listbox.get(selected_alarm_index)

        for idx, alarm in enumerate(database):
            if alarm.time == selected_timer and alarm.state:
                alarm.state = False
                main_listbox.itemconfig(idx, bg='red')

            else:
                alarm.stae = True
                main_listbox.itemconfig(idx, bg='green')
    main_listbox.select_clear(0, 'end')


def main():
    database = []

    window = tk.Tk()
    window.title("ALARM CLOCK")

    top_frame = tk.Frame(window)
    top_frame.pack()
    bottom_frame = tk.Frame(window)
    bottom_frame.pack(side=tk.BOTTOM)
    middle_frame = tk.Frame(window)
    middle_frame.pack(side=tk.BOTTOM)

    tk.Label(top_frame, text="Alarm (hh:mm)").pack()
    input_widget = tk.Entry(top_frame)
    input_widget.pack()

    main_listbox = tk.Listbox(middle_frame, height=5)
    main_listbox.pack()

    button = tk.Button(window, text="Save", command=lambda: save(
        input_widget, database, main_listbox, window))
    button.pack()

    button_1 = tk.Button(bottom_frame, text="ON",
                         command=change_state(main_listbox, database))
    button_1.pack(side=tk.LEFT)
    button_2 = tk.Button(bottom_frame, text="OFF",
                         command=change_state(main_listbox, database))
    button_2.pack(side=tk.LEFT)
    # button_3 = tk.Button(bottom_frame, text="DELET", command=delet_alarm(
    #     main_listbox, database, listbox_database))
    # button_3.pack(side=tk.LEFT)

    window.mainloop()


main()

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 13:19
von __deets__
Du rufst die ja auch direkt auf. Statt mit functools.partial Funktionen zu bauen, die ihre Argumente angebunden haben. Auch das wird hier permanent durchgekaut. Auch und gerade im Zusammenhang mit Tk.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 13:23
von Sirius3
Warum benutzt Du beim ersten Knopf `lambda`, bei den anderen beiden aber nicht? Statt `lambda` wäre functools.partial besser.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 14:19
von Hillson
@Sirius3: Ich hatte das lambda vergessen bei den ON/OFF Buttons. Das lambda beim Save Button musste ich einbauen, weil durch den Umbau die ganzen globalen Variablen weggefallen sind. Dadurch musste ich Parameter beim Aufruf übergeben und da hatte ich gefunden, dass man das mit lambda machen kann.

Und jetzt beim zweiten Button hatte ich das anscheinend schon wieder vergessen. Was zum einen wohl daran liegt, dass ich damals beim ersten Button eine Fehlermeldung bekommen hatte und dieses Mal nicht. Dadurch hatte ich nicht wirklich einen Anhaltspunkt. Und zum anderen daran, dass ich damals schon nicht wirklich verstanden habe warum ich hier jetzt ein lambda verwenden muss und nicht einfach,

Code: Alles auswählen

button = tk.Button(window, text="Save", command=save(input_widget, database, main_listbox, window)
schreiben kann. Im einfachen Programmablauf ruft man doch so auch Funktionen auf und übergibt die Parameter in der Klammer.

Den unterschied zwischen lambda und functools.partial habe ich jetzt nach einigen Beispielen auch immer noch nicht 100% verstanden. Was ich rausgefunden habe ich das lambda keine Daten speichert die nicht in den Parametern übergeben werden. Außerdem wird lambda und functools.partial wohl benutzt wenn bestimmte Parameter einer Funktion wiederholt gleich sind, dann muss man diese nicht immer wieder übergeben.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 14:28
von __deets__
Wenn Python einen Ausdruck der Form

Code: Alles auswählen

funktion(argument)
sieht, was macht es dann? Richtig, es ruft funktion mit argument auf.

Was aber das Argument command beim Button sein soll ist ein *CALLBACK*, deutsch Rueckruffunktion. Die soll nicht IN DEM MOMENT aufgerufen werden. So wie Python das nunmal macht, wenn du da

Code: Alles auswählen

save(input_widget, ...)
hinschreibst. Sondern die soll DANN aufgerufen werden, WENN der Benutzer den Knopf drueckt.

Darum muss man da eine FUNKTION (strenggenommen ein callable, also etwas aufrufbares) uebergeben. Und sie NICHT direkt aufrufen. Also zb

Code: Alles auswählen

lambda: print("hallo")
. Das liefert ein Funktionsobjekt zurueck, und das kann man dann aufrufen.

Code: Alles auswählen

foo = lambda: print("hallo")
print(foo) # nix hallo
print(foo()) # jetzt hallo
Und functools.partial erlaubt aus einer Funktion, die Argumente bekommt, eine Funktion zu machen, die weniger (bis keine) Argumente bekommt, die dafuer dann schon festgelegt sind.

Code: Alles auswählen

foo = lambda arg: print(arg)
bar = functools.partial(foo, "welt")
bar()

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 14:46
von Hillson
Danke für die ausführliche Erklärung.

Wenn ich die Sache jetzt aber komplett richtig verstanden habe, ist es in meinem Fall grundsätzlich egal ob ich lambda oder partial verwende, da ich ja alle benötigten Werte immer wieder als Argumente übergebe wenn ein Button gedrückt wird. Richtig?

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 15:06
von __deets__
Theoretisch ist es egal. Praktisch ist partial besser, weil es eine Reihe von Fallen, in die man beim lambda tappen kann, nicht gibt. Kannst ja mal hierueber sinnieren:

Code: Alles auswählen

from functools import partial
callbacks = []
for i in range(10):
    callbacks.append(lambda: print(i))
    callbacks.append(partial(print, i))
for c in callbacks:
    c()

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 15:37
von Hillson
So ein ähnliches Beispiel habe ich auch schon gesehen gehabt bei meiner Suche. Da gehts ja um die Sache die ich auch schon angesprochen hatte, dass Lambda nichts speichert. Trotzdem verstehe ich das in dem Beispiel aber nicht wirklich warum der Output unterschiedlich bei Lambda ist :D

Den Teil von callbacks mit den partial lasse ich jetzt mal außen vor.

Code: Alles auswählen

for i in range(3):
    callbacks.append(lambda: print(i))
    #callbacks.append(partial(print, i))
Hier nach müsste callbacks doch so aussehen oder nicht:

Code: Alles auswählen

[lambda: print(0),lambda: print(1),lambda: print(2)]
lambda muss doch hier eigentlich gar nichts speichern, weil der Eintrag in die Liste doch direkt nach jedem Durchlauf gemacht wird und damit i für den Eintrag doch auch fest sein sollte. Achso oder ist das so gemeint mit dem Speichern, dass bei lambda pro Funktion immer nur die letzte Definition des Arguments übernommen wird?

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 15:42
von __deets__
Jo. Das ist damit gemeint. Ein closure (das ist das, was da implizit erzeugt wird) erfasst nur die NAMEN, nicht die WERTE beim Moment seiner Erzeugung. Und ein closure erzeugt man, wenn man eine Funktion (oder diverse andere Dinge) anlegt, die aus der Umbegung Namen referenzieren.

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 15:58
von Hillson
Hast du auch noch ein sinnvolles einfaches Beispiel für die Nutzung von closures?

Re: Probleme mit erstem Projekt. (Wecker)

Verfasst: Donnerstag 2. Januar 2020, 16:19
von __deets__
Nein. Wenn dich das Thema interessiert, findet Google bestimmt viele tolle Beispiele und Erklärungen. Jetzt hast du ja ein Stichwort.