The source code for the filedialog module can be found within the Tkinter source code in a separate file named filedialog.py. You are encouraged to take a look at its implementation.
If you are feeling adventurous and want to further explore the Text Editor program, I encourage you to have a look at the source code for Python's built-in editor named IDLE, which is written in Tkinter. The source code for IDLE can be found in your local Python library directory in a folder called idlelib. On Linux Mint, this is located at /usr/lib/python3.4/idlelib.
Read the official Python styling guide, which is specified in the PEP8 documentation at https://www.python.org/dev/peps/pep-0008.
If you like, try to implement syntax highlighting ...