Blog: 2024-10-26
Jump to navigation
Jump to search
Here's my silly little quicktime event with tkinter
import tkinter as tk
from tkinter import ttk, PhotoImage
# Create the main window
root = tk.Tk()
root.title("Image in Tkinter")
root.geometry('600x600')
# Load the image
image = PhotoImage(file="trogdor.png")
# Create a label to display the image
image_label = tk.Label(root, image=image)
image_label.pack()
win = False
def button_pressed():
win = True
print('You stab the dragon in the neck and it dies. Nice one')
root.destroy()
def game_over():
if win:
return
print('The dragon eats you with a loud CHOMP')
root.destroy()
image_label.after(5000, game_over)
button = ttk.Button(root, text='Stab dragon', command=button_pressed)
button.pack(expand=True)
# Start the Tkinter event loop
root.mainloop()