import tkinter as tk
def animate():
# Move every object with the tag "box_group" 2 pixels right and 1 pixel down
canvas.move("box_group", 2, 1)
# Check boundaries (optional) to reset or bounce
pos = canvas.coords(rect)
if pos[2] < 600: # If the right edge hasn't hit the canvas boundary
root.after(20, animate)
root = tk.Tk()
canvas = tk.Canvas(root, width=900, height=600, bg="white")
canvas.pack()
# 1. Create Rectangle
rect = canvas.create_rectangle(250, 50, 50, 100, fill="skyblue", tags="box_group")
# 2. Create Text (centered inside the rectangle's initial coordinates)
text = canvas.create_text(150, 75, text="SMA INFORMATIKA CIAMIS", tags="box_group")
# Start Animation
animate()
root.mainloop()

Tidak ada komentar:
Posting Komentar