I'm learning Python and want to make a small text editor that would allow the code collapsing like when def a Function, how you can collapse that to a single line.
I'm thinking of using Tkinter but would be open to other environments.
I mainly want to know what widget I should use, I'd like to think that I'd be able to figure out how to do it. (Although an example is always welcome.)
Thanks.
You could consider the Scintilla text editing component, with bindings for Python (and other languages.) The Scintilla text editing widget is the basis for the SciTE text editor.
SciTE supports code folding, so it is certainly doable - it may even be a built in part of Scintilla.
From the SciTE website:

Scintilla is a free source code editing component. It comes with
  complete source code and a license that permits use in any free
  project or commercial product.
As well as features found in standard text editing components,
  Scintilla includes features especially useful when editing and
  debugging source code. These include support for syntax styling, error
  indicators, code completion and call tips. The selection margin can
  contain markers like those used in debuggers to indicate breakpoints
  and the current line. Styling choices are more open than with many
  editors, allowing the use of proportional fonts, bold and italics,
  multiple foreground and background colours and multiple fonts.
SciTE is a SCIntilla based Text Editor. Originally built to
  demonstrate Scintilla, it has grown to be a generally useful editor
  with facilities for building and running programs. It is best used for
  jobs with simple configurations - I use it for building test and
  demonstration programs as well as SciTE and Scintilla, themselves.
Python: How to program an IDE Code collapsing?