1

I was trying to understand the Tkinter library code a little bit better, so I've been trying to place breakpoints in different places and understand the flow of code. To my surprise, the debugger does not stop at many points of the library code that I know are being executed.

I'm unclear on whether this is a spyder bug, or something funny in how Tkinter creates a loop for the GUI / interfaces with the OS.

This is the simple test-driving code that I am using:

from IPython import get_ipython   
get_ipython().magic('reset -sf')

import tkinter as tk

x = tk.Pack()

I initially modified tkinter's init.py file at line 2144 to introduce a breakpoint here:

pack = configure = config = pack_configure

To my consternation, the debugger never stops here, which is very surprising to me given that commenting this line out causes an error in my test-drive code above.

I then added a simple print statement after line 2144 above, sys.stdout.write('beep') sys.stdout.flush()

Again, to my surprise, the 'beep' is only printed occasionally / seemingly stochastically. This is despite me clearing the workspace in the test driving script (the ipython %reset -sf command), as well as closing and re-opening anaconda/spyder.

Is there some kind of remedy to this, so that I can get more consistent behavior?

Thanks.

user49404
  • 732
  • 6
  • 22

0 Answers0