Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle
- import tkinter as tk
- def forward():
- t.forward(100)
- def back():
- t.back(100)
- def left():
- t.left(90)
- def right():
- t.right(90)
- root = tk.Tk()
- canvas = tk.Canvas(master = root, width = 500, height = 500)
- canvas.pack()
- t = turtle.RawTurtle(canvas)
- t.pencolor("#ff0000") # Red
- ts = t.getscreen()
- ts.addshape(r"d:\Downloads\rabbit.gif")
- shape =((0, 0), (10, 10), (20, 0), (10, -10))
- # registering the new shape
- ts.register_shape('diamond', shape)
- #t.shape("diamond")
- print(ts.getshapes())
- #t.shape("d:\\Downloads\\rabbit.gif")
- t.penup() # Regarding one of the comments
- t.pendown() # Regarding one of the comments
- tk.Button(master = root, text = "Forward", command = forward).pack(side = tk.LEFT)
- tk.Button(master = root, text = "Back", command = back).pack(side = tk.LEFT)
- tk.Button(master = root, text = "Left", command = left).pack(side = tk.LEFT)
- tk.Button(master = root, text = "Right", command = right).pack(side = tk.LEFT)
- root.mainloop()
Add Comment
Please, Sign In to add comment