From c0ccb6b9df6772fb34f1e5df18872dd3fe76ddb7 Mon Sep 17 00:00:00 2001 From: Vhou-Atroph Date: Thu, 28 Mar 2024 00:36:28 -0500 Subject: [PATCH] early App class it will likely become the new home of the entire gag calculator, for now it just holds the asset path (which hasnt even been fully replaced in app.py yet, but programming on this 2gb rpi is a nightmare) --- src/tt_damage_calculator/app.py | 9 +++------ src/tt_damage_calculator/widgets.py | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/tt_damage_calculator/app.py b/src/tt_damage_calculator/app.py index 1b4c6cb1..8ef869fb 100644 --- a/src/tt_damage_calculator/app.py +++ b/src/tt_damage_calculator/app.py @@ -18,11 +18,8 @@ # Window global window -window = Tk() -window.title("Toontown Damage Calculator") -asset_path = str(pathlib.Path(__file__).parent.resolve()) -if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): - asset_path = os.getcwd() +window = widgets.App() +asset_path = window.asset_path whole_cream_pie_img = PhotoImage(file=asset_path + "/assets/img/whole-cream-pie.png") window.iconphoto(True, whole_cream_pie_img) window.resizable(0, 0) @@ -407,4 +404,4 @@ def add_custom_gag(): calculations_menu.add_checkbutton(label="Lock Status", variable=status_lock, onvalue=True, offvalue=False, accelerator=settings.keybinds.lock) calculations_menu.add_command(label="Custom Gags") toolbar.add_cascade(label="Calculations", menu=calculations_menu) -window.configure(menu=toolbar) \ No newline at end of file +window.configure(menu=toolbar) diff --git a/src/tt_damage_calculator/widgets.py b/src/tt_damage_calculator/widgets.py index b14131d3..50ae0e89 100644 --- a/src/tt_damage_calculator/widgets.py +++ b/src/tt_damage_calculator/widgets.py @@ -2,7 +2,8 @@ TT-Damage-Calculator Copyright (C) 2022-2024 Vhou-Atroph """ -from tkinter import BooleanVar, Frame, Label, Text, Button, PhotoImage, NORMAL, DISABLED, WORD, END +import os, pathlib, sys +from tkinter import BooleanVar, Tk, Frame, Label, Text, Button, PhotoImage, NORMAL, DISABLED, WORD, END from . import tt_damage_calculator @@ -86,4 +87,17 @@ def press(self, output:HistoryBox, orgstate:bool): gaginfo = self.gag.button_press(orgstate) self.configure(text=int(self.cget("text")) + 1) output.add("Gag used: " + gaginfo[1] + " (" + str(gaginfo[0]) + ")\n") - #TODO: implement gag calculation here \ No newline at end of file + #TODO: implement gag calculation here + +class App(Tk): + """Class for the gag calculator's full app.""" + + def __init__(self): + Tk.__init__(self) + self.title("Toontown Damage Calculator") + self.get_asset_path() + + def get_asset_path(self): + self.asset_path = str(pathlib.Path(__file__).parent.resolve()) + if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): + self.asset_path = os.getcwd()