Debug a problem in tk85.dll in an application that embeds the Python interpreter Debug a problem in tk85.dll in an application that embeds the Python interpreter tkinter tkinter

Debug a problem in tk85.dll in an application that embeds the Python interpreter


First, I let you know that I identified race conditions in Python's Tkinter when used with nonthreaded Tcl/Tk (Py2 is shipped with that) and proposed a fix. I'm not sure I fixed all the possible race conditions but I did fix all that I have run into.

Now, to be able to debug Tcl/Tk issues, you need to build Python with a debug version of Tcl/Tk and embed that. This should give you the ability to look into tk*.dll in debugger and see what's wrong.

  • Get the source code for your Python version and make the following changes:

    --- a/PCbuild/prepare_tcltk.bat+++ b/PCbuild/prepare_tcltk.bat@@ -46,10 +46,10 @@ rem if ERRORLEVEL 1 (echo Cannot locate python.exe on PATH or as PYTHON variable call "%PCBUILD%\get_externals.bat" --tkinter-src %ORG_SETTING%-%MSBUILD% "%PCBUILD%\tcl.vcxproj" /p:Configuration=Release /p:Platform=Win32-%MSBUILD% "%PCBUILD%\tk.vcxproj" /p:Configuration=Release /p:Platform=Win32-%MSBUILD% "%PCBUILD%\tix.vcxproj" /p:Configuration=Release /p:Platform=Win32+%MSBUILD% "%PCBUILD%\tcl.vcxproj" /p:Configuration=Debug /p:Platform=Win32+%MSBUILD% "%PCBUILD%\tk.vcxproj" /p:Configuration=Debug /p:Platform=Win32+%MSBUILD% "%PCBUILD%\tix.vcxproj" /p:Configuration=Debug /p:Platform=Win32-%MSBUILD% "%PCBUILD%\tcl.vcxproj" /p:Configuration=Release /p:Platform=x64-%MSBUILD% "%PCBUILD%\tk.vcxproj" /p:Configuration=Release /p:Platform=x64-%MSBUILD% "%PCBUILD%\tix.vcxproj" /p:Configuration=Release /p:Platform=x64+%MSBUILD% "%PCBUILD%\tcl.vcxproj" /p:Configuration=Debug /p:Platform=x64+%MSBUILD% "%PCBUILD%\tk.vcxproj" /p:Configuration=Debug /p:Platform=x64+%MSBUILD% "%PCBUILD%\tix.vcxproj" /p:Configuration=Debug /p:Platform=x64
  • run PCBuild\prepare_tcltk.bat from VS command prompt to download and build Tcl/Tk from source

  • Now build a debug Python as usual (PCBuild\readme.txt has the instructions).