Untitled

mail@pastecode.io avatar
unknown
python
7 months ago
699 B
1
Indexable
Never
import tkinter as tk

level = 0


def train_pet():
  global level
  level += 1
  pet_level.set("PET LEVEL: {}".format(level))
  print(level)


# Create the main window
root = tk.Tk()
root.title("Virtual Pet")

pet_status = tk.StringVar()
pet_status.set("I AM THE GREATEST PET EVER")

pet_label = tk.Label(root, textvariable=pet_status, font=("Helvetica", 16))
pet_label.pack()

pet_level = tk.StringVar()
pet_level.set("PET LEVEL: 0")
pet_level_label = tk.Label(root,
                           textvariable=pet_level,
                           font=("Helvetica", 16))
pet_level_label.pack()

train_button = tk.Button(root, text="Train Pet", command=train_pet)
train_button.pack()

root.mainloop()
Leave a Comment