O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adjusting our text editor for portability

The main changes we will need to make will be in the texteditor.py file. Open up this file and add the following:

...import osfrom pathlib import Path...def __init__(self):    ...    self.config_dir = os.path.join(str(Path.home()), ".tkedit")    self.default_scheme_path = os.path.join(self.config_dir,                               'schemes/default.yaml')    self.python_language_path = os.path.join(self.config_dir,                               'languages/python.yaml')    self.font_scheme_path = os.path.join(self.config_dir,                               'schemes/font.yaml')    self.create_config_directory_if_needed()

In order to access the user's home directory independent of the OS, we will use the pathlib module. The folder where we will be storing the user's YAML files will be called .tkedit and will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required