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 ...

Get Tkinter GUI Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.