Skip to content

Commit

Permalink
Improved fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
kelltom committed May 12, 2023
1 parent 73923e1 commit d22c000
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 49 deletions.
10 changes: 6 additions & 4 deletions src/OSBC.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
from model import Bot, RuneLiteBot
from utilities.game_launcher import Launchable
from view import *
from view.fonts import *
from view.fonts.fonts import *

customtkinter.set_appearance_mode("Dark") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"


class App(customtkinter.CTk):
WIDTH = 650
WIDTH = 680
HEIGHT = 480
DEFAULT_GRAY = ("gray50", "gray30")

Expand Down Expand Up @@ -114,6 +114,8 @@ def build_ui(self): # sourcery skip: merge-list-append, move-assign-in-block
# Dropdown menu for selecting a game
self.menu_game_selector = customtkinter.CTkOptionMenu(
master=self.frame_left,
font=body_large_font(),
dropdown_font=body_med_font(),
values=list(self.btn_map.keys()),
command=self.__on_game_selector_change,
)
Expand Down Expand Up @@ -146,7 +148,7 @@ def build_ui(self): # sourcery skip: merge-list-append, move-assign-in-block
fg_color="#2a2d2e",
hover_color=self.DEFAULT_GRAY,
text="Settings",
font=button_font(),
font=button_med_font(),
image=self.img_settings,
command=self.__on_settings_clicked,
)
Expand Down Expand Up @@ -177,7 +179,7 @@ def __create_button(self, bot_key: str, launchable: bool = False):
else:
text = text
tooltip = False
font = button_font(10) if len(self.models[bot_key].bot_title) > shrink_length else button_font(12)
font = button_small_font() if len(self.models[bot_key].bot_title) > shrink_length else button_med_font()

btn = customtkinter.CTkButton(
master=self.scrollable_frame_left,
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/options_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import customtkinter

from view.fonts import *
from view.fonts.fonts import *


class OptionsBuilder:
Expand Down Expand Up @@ -131,7 +131,7 @@ def __init__(self, parent, title: str, option_info: dict, controller):
raise Exception("Unknown option type")

# Save button
self.btn_save = customtkinter.CTkButton(master=self, text="Save", font=button_font(), command=lambda: self.save(window=parent))
self.btn_save = customtkinter.CTkButton(master=self, text="Save", font=button_med_font(), command=lambda: self.save(window=parent))
self.btn_save.grid(row=self.num_of_options + 2, column=0, columnspan=2, pady=20, padx=20)

def change_slider_val(self, key, value):
Expand Down
42 changes: 28 additions & 14 deletions src/view/fonts.py → src/view/fonts/fonts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import customtkinter as ctk

default_font_family = "Roboto"
default_font_family = "Trebuchet MS"
default_font_size = 14


Expand All @@ -15,50 +15,64 @@ def title_font():
return get_font(size=24, weight="bold")


def heading_font():
def heading_font(size=18):
"""
Preset for headings.
"""
return get_font(size=18, weight="bold")
return get_font(size=size, weight="bold")


def subheading_font():
def subheading_font(size=16):
"""
Preset for subheadings.
"""
return get_font(size=16, weight="bold")
return get_font(size=size, weight="bold")


def body_large_font(size=15):
"""
Preset for body text.
"""
return get_font(size=size)


def body_font():
def body_med_font(size=14):
"""
Preset for body text.
"""
return get_font(size=14)
return get_font(size=size)


def button_med_font(size=14):
"""
Preset for button text.
"""
return get_font(size=size, weight="bold")


def button_font(size=12):
def button_small_font(size=12):
"""
Preset for button text.
"""
return get_font(size=size, weight="bold")


def small_font():
def small_font(size=12):
"""
Preset for small text, such as captions or footnotes.
"""
return get_font(size=12)
return get_font(size=size)


def micro_font():
def micro_font(size=10):
"""
Preset for micro text, such as version stamps.
"""
return get_font(size=10)
return get_font(size=size)


def log_font():
def log_font(size=12):
"""
Preset for log text.
"""
return get_font(family="Courier", size=12)
return get_font(family="Cascadia Code", size=size)
10 changes: 5 additions & 5 deletions src/view/home_view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import customtkinter

from view.fonts import *
from view.fonts.fonts import *


class HomeView(customtkinter.CTkFrame):
Expand Down Expand Up @@ -33,7 +33,7 @@ def __init__(self, parent, main, game_title: str):
"Basic HomeViews are not fully implemented yet. Once support for non-RuneLite games is added to OSBC, this will be updated. <Game description and"
" user instructions here>. Click the button below to unlock the scripts."
)
self.label_note = customtkinter.CTkLabel(master=self, text=self.note, font=body_font())
self.label_note = customtkinter.CTkLabel(master=self, text=self.note, font=body_med_font())
self.label_note.bind(
"<Configure>",
lambda e: self.label_note.configure(wraplength=self.label_note.winfo_width() - 20),
Expand All @@ -45,7 +45,7 @@ def __init__(self, parent, main, game_title: str):
self.label_warning = customtkinter.CTkLabel(
master=self,
text=self.warning,
font=body_font(),
font=body_med_font(),
text_color="orange",
)
self.label_warning.bind(
Expand All @@ -58,15 +58,15 @@ def __init__(self, parent, main, game_title: str):
self.btn_skip = customtkinter.CTkButton(
master=self,
text="I Understand",
font=button_font(),
font=button_med_font(),
fg_color="gray40",
hover_color="gray25",
command=self.__skip,
)
self.btn_skip.grid(row=5, column=0, sticky="nwes", padx=40, pady=(0, 15))

# Status label
self.label_status = customtkinter.CTkLabel(master=self, text="", font=body_font())
self.label_status = customtkinter.CTkLabel(master=self, text="", font=body_med_font())
self.label_status.grid(row=6, column=0, sticky="nwes")
self.label_status.bind(
"<Configure>",
Expand Down
14 changes: 7 additions & 7 deletions src/view/home_view_runelite.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import customtkinter

import utilities.game_launcher as launcher
from view.fonts import *
from view.fonts.fonts import *


class RuneLiteHomeView(customtkinter.CTkFrame):
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(self, parent, main, game_title: str):
+ "step if you know your client is already configured. If a script has a rocket icon next to its name, RuneLite should instead be launched using"
" the dedicated button provided by the script."
)
self.label_note = customtkinter.CTkLabel(master=self, text=self.note, font=body_font())
self.label_note = customtkinter.CTkLabel(master=self, text=self.note, font=body_med_font())
self.label_note.bind(
"<Configure>",
lambda e: self.label_note.configure(wraplength=self.label_note.winfo_width() - 20),
Expand All @@ -57,7 +57,7 @@ def __init__(self, parent, main, game_title: str):
self.label_warning = customtkinter.CTkLabel(
master=self,
text=self.warning,
font=body_font(),
font=body_med_font(),
text_color="orange",
)
self.label_warning.bind(
Expand All @@ -70,7 +70,7 @@ def __init__(self, parent, main, game_title: str):
self.btn_replace = customtkinter.CTkButton(
master=self,
text=f"Launch {game_title}",
font=button_font(),
font=button_med_font(),
command=self.__launch,
)
self.btn_replace.grid(row=5, column=0, sticky="nwes", padx=40, pady=(0, 15))
Expand All @@ -79,7 +79,7 @@ def __init__(self, parent, main, game_title: str):
self.btn_skip = customtkinter.CTkButton(
master=self,
text="Skip",
font=button_font(),
font=button_med_font(),
fg_color="gray40",
hover_color="gray25",
command=self.__skip,
Expand All @@ -90,15 +90,15 @@ def __init__(self, parent, main, game_title: str):
self.btn_skip = customtkinter.CTkButton(
master=self,
text="Reset Saved Path",
font=button_font(),
font=button_med_font(),
fg_color="DarkRed",
hover_color="red",
command=self.__reset_saved_path,
)
self.btn_skip.grid(row=7, column=0, sticky="ns", padx=10, pady=(0, 15))

# Status label
self.label_status = customtkinter.CTkLabel(master=self, text="", font=body_font())
self.label_status = customtkinter.CTkLabel(master=self, text="", font=body_med_font())
self.label_status.grid(row=8, column=0, sticky="nwes")
self.label_status.bind(
"<Configure>",
Expand Down
12 changes: 6 additions & 6 deletions src/view/info_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import utilities.settings as settings
from utilities.game_launcher import Launchable
from view.fonts import *
from view.fonts.fonts import *


class InfoFrame(customtkinter.CTkFrame):
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(self, parent, title, info): # sourcery skip: merge-nested-ifs
self.lbl_script_title.grid(column=0, row=0, sticky="wns", padx=20, pady=15)

# -- script description
self.lbl_script_desc = customtkinter.CTkLabel(master=self, text=info, font=small_font(), justify=tkinter.CENTER)
self.lbl_script_desc = customtkinter.CTkLabel(master=self, text=info, font=body_med_font(), justify=tkinter.CENTER)
self.lbl_script_desc.grid(column=0, row=2, sticky="nwes", padx=15)
self.lbl_script_desc.bind(
"<Configure>",
Expand Down Expand Up @@ -97,7 +97,7 @@ def __init__(self, parent, title, info): # sourcery skip: merge-nested-ifs
self.btn_play = customtkinter.CTkButton(
master=self.btn_frame,
text="Play",
font=button_font(),
font=button_med_font(),
text_color="white",
image=self.img_play,
command=self.play_btn_clicked,
Expand All @@ -109,7 +109,7 @@ def __init__(self, parent, title, info): # sourcery skip: merge-nested-ifs
self.btn_stop = customtkinter.CTkButton(
master=self.btn_frame,
text="Stop",
font=button_font(),
font=button_med_font(),
text_color="white",
fg_color="#910101",
hover_color="#690101",
Expand All @@ -122,7 +122,7 @@ def __init__(self, parent, title, info): # sourcery skip: merge-nested-ifs
self.btn_options = customtkinter.CTkButton(
master=self.btn_frame,
text="Options",
font=button_font(),
font=button_med_font(),
text_color="white",
fg_color="#d97b00",
hover_color="#b36602",
Expand All @@ -134,7 +134,7 @@ def __init__(self, parent, title, info): # sourcery skip: merge-nested-ifs
self.btn_launch = customtkinter.CTkButton(
master=self.btn_frame,
text="Launch Game",
font=button_font(),
font=button_med_font(),
text_color="white",
fg_color="#616161",
image=self.img_start,
Expand Down
2 changes: 1 addition & 1 deletion src/view/output_log_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import customtkinter

from view.fonts import *
from view.fonts.fonts import *


class OutputLogFrame(customtkinter.CTkFrame):
Expand Down
6 changes: 3 additions & 3 deletions src/view/settings_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from PIL import Image, ImageTk

import utilities.settings as settings
from view.fonts import *
from view.fonts.fonts import *


class SettingsView(customtkinter.CTkFrame):
Expand Down Expand Up @@ -46,7 +46,7 @@ def __init__(self, parent):
self.frame_keybinds.columnconfigure(0, weight=1) # lbl label
self.frame_keybinds.columnconfigure(1, weight=0) # lbl keybind
self.frame_keybinds.columnconfigure(2, weight=0) # btn set
self.lbl_keybinds = customtkinter.CTkLabel(master=self.frame_keybinds, text="Bot start/stop keybind: ", font=body_font())
self.lbl_keybinds = customtkinter.CTkLabel(master=self.frame_keybinds, text="Bot start/stop keybind: ", font=body_med_font())
self.lbl_keybinds.grid(row=0, column=0, padx=20, pady=20)
self.entry_keybinds = customtkinter.CTkLabel(
master=self.frame_keybinds, text=f"{settings.keybind_to_text(self.current_keys) if self.current_keys else 'None'}"
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(self, parent):
widget_list[i].grid(row=i, column=0, columnspan=2, sticky="nsew", padx=20, pady=20)

# Save button
self.btn_save = customtkinter.CTkButton(master=self, text="Save", font=button_font(), command=lambda: self.save(window=parent))
self.btn_save = customtkinter.CTkButton(master=self, text="Save", font=button_med_font(), command=lambda: self.save(window=parent))
self.btn_save.grid(row=self.num_of_widgets + 2, column=0, columnspan=2, pady=20, padx=20)

def __modify_keybind(self):
Expand Down
2 changes: 1 addition & 1 deletion src/view/sprite_scraper_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import customtkinter

from utilities.sprite_scraper import SpriteScraper
from view.fonts import *
from view.fonts.fonts import *

scraper = SpriteScraper()

Expand Down

0 comments on commit d22c000

Please sign in to comment.