I was trying to debug my python tkinter app but I noticed that my debugger just stopped working when it reached tkinter's mainloop() method.
Although my app was working as expected, interacting with it did not seem to update my debugger or variable values. After searching around I found very little information on the topic and that it is not possible to debug a tkinter app while in the mainloop since the core library is written in C.
Surely there must be some workarounds?
At the moment I am finding myself having to debug each and every interaction on my tkinter app manually, which is extremely time confusing and inefficient as my app grows complex.
Don't put breakpoints before the mainloop. Put a breakpoint in the action you want to debug, e.g. a button command:
def command():
    print("hello")  # <-- breakpoint here
tk.Button(frame,
          text="Hello",
          command=command)
Then the debugger can stop there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With