This commit is contained in:
2025-03-18 13:05:36 +03:00
parent 3b4be94f7a
commit 0fb107d952
12 changed files with 874 additions and 0 deletions

3
utils/__init__.py Normal file
View File

@@ -0,0 +1,3 @@
from . import fonts
from .params import Strings, Icons
from .misc import base_path

85
utils/fonts.py Normal file
View File

@@ -0,0 +1,85 @@
# https://github.com/kelltom/OS-Bot-COLOR/
import pathlib
import customtkinter as ctk
fonts_path = pathlib.Path(__file__).parent
ctk.FontManager.load_font(str(fonts_path.joinpath("CascadiaCode.ttf")))
def get_font(family="Trebuchet MS", size=14, weight="normal", slant="roman", underline=False):
"""
Gets a font object with the given parameters. This is a wrapper for ctk.CTkFont. Provides
defaults for app theme fonts.
"""
return ctk.CTkFont(family=family, size=size, weight=weight, slant=slant, underline=underline)
def title_font():
"""
Preset for titles (largest).
"""
return get_font(size=24, weight="bold")
def heading_font(size=20):
"""
Preset for headings.
"""
return get_font(size=size, weight="bold")
def subheading_font(size=16):
"""
Preset for subheadings.
"""
return get_font(size=size, weight="bold")
def body_large_font(size=15):
"""
Preset for body text.
"""
return get_font(size=size)
def body_med_font(size=14):
"""
Preset for body text.
"""
return get_font(size=size)
def button_med_font(size=14):
"""
Preset for button text.
"""
return get_font(size=size, weight="bold")
def button_small_font(size=12):
"""
Preset for button text.
"""
return get_font(size=size, weight="bold")
def small_font(size=12):
"""
Preset for small text, such as captions or footnotes.
"""
return get_font(size=size)
def micro_font(size=10):
"""
Preset for micro text, such as version stamps.
"""
return get_font(size=size)
def log_font(size=12):
"""
Preset for log text.
"""
return get_font(family="Cascadia Code", size=size)

12
utils/misc.py Normal file
View File

@@ -0,0 +1,12 @@
import sys
from pathlib import Path
def base_path():
# PyInstaller creates a temp folder and stores path in _MEIPASS
try:
# noinspection PyUnresolvedReferences,PyProtectedMember
return Path(sys._MEIPASS).resolve()
except AttributeError:
return Path().resolve()

22
utils/params.py Normal file
View File

@@ -0,0 +1,22 @@
class Strings:
# login box,
ok = "ok"
cancel = "cancel"
login = "login"
password = "password"
# message box
info = "Info"
warning = "Warning"
error = "Error"
yesno = "Question"
class Icons:
# message box
info = ""
warning = "⚠️"
error = ""
yesno = "?"