5

According to the Python 3 documentation, Chapter 25.1: tkinter - Python interface to Tcl/Tk:

The Tk interface is located in a binary module named _tkinter. This module contains the low-level interface to Tk

Where can I obtain the source code of this module?

I checked python/cython on GitHub, but could not find it.

Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
  • 2
    The source for _tkinter won't be very interesting, as it's just a wrapper for a tcl interpreter. What are you really looking for? If you're curious how widgets are actually constructed you'll want to look at the source code for tcl/tk. – Bryan Oakley Jun 28 '17 at 11:31
  • @BryanOakley I can't speak for the OP but in my case, I am looking to extend the capability of the Canvas widget, which will require Tk and possibly Tkinter changes. – yamex5 Sep 10 '22 at 09:49

2 Answers2

5

Found it here on GitHub for cpython

Hugues M.
  • 19,846
  • 6
  • 37
  • 65
4

Check also this answer here which is related to your problem and gives this source (https://hg.python.org/cpython/file/3.6/) from python.org.

How did I get there? In python,

>>> import _tkinter
>>> _tkinter.__file__
'/usr/lib/python2.7/lib-dynload/_tkinter.so'

Then in Google: "Python lib-dynload source".

Manu CJ
  • 2,629
  • 1
  • 18
  • 29