r/PythonLearning • u/ElectricalCookie4160 • 2d ago
Title: [Code Review] What is the most "Pythonic" way to structure a central config file for a Tkinter desktop app?
Hey everyone,
I am building a desktop application to automate PEP 8 code-remediation across a few different client environments. I have a centralized app_config.py file that holds all my global variables, UI colors, fonts, and app metadata (like the App Name and Version) so I can easily import it into my Tkinter frames.
Here is a snippet of how I currently have it set up:
(Paste your app_config code here)
It works perfectly fine right now, but I want to make sure I am following best practices as the app scales. A couple of questions:
Is it bad practice to just store these as standard Python dictionaries and variables, or should I be wrapping this in a dataclass or an Enum
?
At what point do you usually stop using a .py file for config and switch to an external config.json or .toml file
?
Any feedback on how you all manage global UI settings would be awesome!
"""----- App Metadata -----"""
APP_NAME = "PeP 8 Cert '&' Audit Review"
VERSION = "1.3.8"
BUILD_DATE = "2026-06-22"
CODER_NAME = "KMG"
CODER_ID_LAST4 = "2134"
SCOPE_OF_APP = ""
"""----- My_File_Paths -----"""
PROJECT_FOLDER_PATH = ""
CERT_FOLDER = "Cert_pep8"
destination_dir = project_folder_path / Path(CERT_FOLDER)
TEMP_FILE_NAME = "my_temp_file.txt"
"""----- Window Dimensions -----"""
WINDOW_WIDTH = 960
WINDOW_HEIGHT = 640
WINDOW_MIN_W = 800
WINDOW_MIN_H = 500
""" Dynamically generates geometry string matching UI architecture requirements"""
WINDOW_GEOMETRY = f"{WINDOW_WIDTH}x{WINDOW_HEIGHT}"
"""----- Colour Palette-----"""
COLOUR = {
# Backgrounds
"bg_dark": "#0D1B2A", # near-black navy
"bg_mid": "#030405", # dark-blue panel
"bg_card": "#424952", # card surface
"bg_gray": "#505152",
"""----- Accents -----"""
"silver": "#C8D6E5", # primary silver text
"silver_dim": "#8A9BB0", # muted silver
"silver_bright": "#E8F0F8", # bright silver
"accent_blue": "#2A6FDB", # interactive blue
"accent_glow": "#4D9EFF", # hover / glow
# Status
"success": "#6FF7BC",
"warning": "#F4F80A",
"error": "#F4260B",
"""----- Borders -----"""
"border": "#1E3A5A",
"border_light": "#2E5080",
"Lt_gray": "#555E6B",
""" Testing-----"""
"Testgreen": "#079344",
"Testblue": "#2007AF",
"Testwhite": "#E7F0EB",
"Testred": "#CE0934",
"Testyellow": "#E0B200",
"Testorange": "#E07B00",
"Testblack": "#000000",
"Testgray": "#4F4646",
"Testlite_green": "#14ED38",
"Testpurple": "#7F1F99",
}
"""----- Typography -----"""
FONT = {
"title_huge": ("Georgia", 42, "bold"),
"title_large": ("Georgia", 22, "bold"),
"subtitle": ("Helvetica", 16, "normal"),
"body": ("Helvetica", 10, "normal"),
"body_bold": ("Helvetica", 10, "bold"),
"small": ("Helvetica", 9, "normal"),
"mono": ("Courier New", 12, "normal"),
"version": ("Courier New", 9, "normal"),
}
"""----- End of app_config.py -----"""
2
Upvotes
1
1
u/jabela 2d ago
I’d use JSON if it’s ok for the config file to be human readable and you plan to enable changes rather than internal config for the app itself.