Instead of adding the options programmatically, it is also possible to define them in a separate text file using the following format:
*font: helvetica 10
*header.font: helvetica 18 bold
*subtitle.font: helvetica 14 italic
*Button.foreground: blue
*Button.background: white
*Button.activeBackground: gray
*Button.activeForeground: black
This file should be loaded into the application using the option_readfile() method, and replaces all the calls to option_add(). In our example, let's suppose the file is called my_options_file and it is placed in the same directory as our script:
def __init__(self):
super().__init__()
self.title("Options demo")
self.option_readfile("my_options_file")
# ...
If the file does not exist or its format is invalid, Tkinter will raise TclError.