Skip to content

Commit

Permalink
Update CornHole.py
Browse files Browse the repository at this point in the history
  • Loading branch information
perspector authored Dec 15, 2022
1 parent a24bb5c commit 6217d5a
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions CornHole.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,20 @@ def resetScore():
BlueLabel.pack(side=tk.LEFT, fill=tk.X)
RedLabel.pack(side=tk.RIGHT, fill=tk.X)


# If someone won, then close the label showing they won
if BlueWonBoolean == True:
BlueWon.destroy()
BlueWonBoolean = False
elif RedWonBoolean == True:
RedWon.destroy()
RedWonBoolean = False

# Define and display the blue, red, and reset buttons (They are all reset)
BlueButton = tk.Button(window, text = "Blue Point", bg = "blue", fg = "yellow", width=30, height=15, command = addBlue)
RedButton = tk.Button(window, text = "Red Point", bg = "red", fg = "black", width=30, height=15, command = addRed)
ResetButton = tk.Button(window, text = "Reset", width=10, height=3, command = resetScore)

# place the score labels
BlueLabel.pack(side=tk.LEFT, fill=tk.X)
RedLabel.pack(side=tk.RIGHT, fill=tk.X)

Expand All @@ -108,22 +110,25 @@ def Quit():

while True:
try:
# Title label
title = tk.Label(
text="Corn Hole!!!",
foreground="green",
background="white",
width=175,
height=3
)


# label with blue score
BlueLabel = tk.Label(
textvariable=BlueText,
foreground="blue",
background="white",
width=10,
height=5
)


# label with red score
RedLabel = tk.Label(
textvariable=RedText,
foreground="red",
Expand All @@ -132,24 +137,39 @@ def Quit():
height=5
)

# define the buttons
BlueButton = tk.Button(window, text = "Blue Point", bg = "blue", fg = "yellow", width=30, height=15, command = addBlue)
RedButton = tk.Button(window, text = "Red Point", bg = "red", fg = "black", width=30, height=15, command = addRed)
ResetButton = tk.Button(window, text = "Reset",bg = "orange", fg = "black", width=10, height=3, command = resetScore)
quitButton = tk.Button(window, text = "Quit :[", bg = "yellow", fg = "orange", command = Quit)

# define the image in the center
image = tk.PhotoImage(file="cornHole.png")
imageLabel = tk.Label(image=image)

# display the score labels
BlueLabel.pack(side=tk.LEFT, fill=tk.X)
RedLabel.pack(side=tk.RIGHT, fill=tk.X)

# display the title
title.pack(side=tk.TOP, fill=tk.X)

# display the buttons
BlueButton.pack(side=tk.LEFT, fill=tk.X)
RedButton.pack(side=tk.RIGHT, fill=tk.X)

# display the image
imageLabel.pack(side=tk.TOP, fill=tk.X)

# display the quit button
quitButton.pack(side=tk.BOTTOM, fill=tk.X)

# display the reset score button
ResetButton.pack(side=tk.BOTTOM, fill=tk.X)

# actually show the window and make everything happen
window.mainloop()
except:
except exception as e:
# if there are errors, display the error nicely and stop the program
print(f"There was an error when running CornHole.py\nThe error is:\n{e}")
exit()

0 comments on commit 6217d5a

Please sign in to comment.