Skip to content

Commit

Permalink
GagButton stuff
Browse files Browse the repository at this point in the history
working on gagbutton; it still isn't ready to replace all the button widgets in app
  • Loading branch information
Vhou-Atroph committed May 5, 2024
1 parent 1ad81b3 commit a52ff19
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/tt_damage_calculator/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def __init__(self, parent:Frame, row:int):
class GagButton(Button):
"""Class for the Gag Button widget, a more complicated version of the normal tkinter Button widget."""

def __init__(self, parent:GagFrame, image:PhotoImage, gag:tt_damage_calculator.Gag, output:HistoryBox, orgstate:BooleanVar):
def __init__(self, window:Tk, parent:GagFrame, image:PhotoImage, gag:tt_damage_calculator.Gag):
self.window = window
self.gag = gag
Button.__init__(self, parent)
self['image'] = image
Expand All @@ -81,13 +82,30 @@ def recolor(self, orgstate:bool):
else:
self['bg'] = "#1888D3"
self['activebackground'] = "#186AD3"

def list(self):
"""Determines what list a particular gag belongs to."""

match self.gag.track:
case "Trap":
return self.window.trap
case "Sound":
return self.window.sound
case "Throw":
return self.window.throw
case "Squirt":
return self.window.squirt
case "Drop":
return self.window.drop

def press(self, output:HistoryBox, orgstate:bool):
"""Function to execute when Gag Button is pressed."""

gaginfo = self.gag.button_press(orgstate)
self.configure(text=int(self.cget("text")) + 1)
self.list().append(gaginfo[0])
output.add("Gag used: " + gaginfo[1] + " (" + str(gaginfo[0]) + ")\n")
if self.gag.gtype == "Gag":
self.configure(text=int(self.cget("text")) + 1)
#TODO: implement gag calculation here

class App(Tk):
Expand Down

0 comments on commit a52ff19

Please sign in to comment.