Skip to content

Commit

Permalink
early App class
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Vhou-Atroph committed Mar 28, 2024
1 parent e18e132 commit c0ccb6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/tt_damage_calculator/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
window.configure(menu=toolbar)
18 changes: 16 additions & 2 deletions src/tt_damage_calculator/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
#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()

0 comments on commit c0ccb6b

Please sign in to comment.