|
| 1 | +# View more python learning tutorial on my Youtube and Youku channel!!! |
| 2 | + |
| 3 | +# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg |
| 4 | +# Youku video tutorial: http://i.youku.com/pythontutorial |
| 5 | + |
| 6 | +import tkinter as tk |
| 7 | + |
| 8 | +window = tk.Tk() |
| 9 | +window.title('my window') |
| 10 | +window.geometry('200x200') |
| 11 | + |
| 12 | +canvas = tk.Canvas(window, bg='blue', height=100, width=200) |
| 13 | +image_file = tk.PhotoImage(file='ins.gif') |
| 14 | +image = canvas.create_image(10, 10, anchor='nw', image=image_file) |
| 15 | +x0, y0, x1, y1= 50, 50, 80, 80 |
| 16 | +line = canvas.create_line(x0, y0, x1, y1) |
| 17 | +oval = canvas.create_oval(x0, y0, x1, y1, fill='red') |
| 18 | +arc = canvas.create_arc(x0+30, y0+30, x1+30, y1+30, start=0, extent=180) |
| 19 | +rect = canvas.create_rectangle(100, 30, 100+20, 30+20) |
| 20 | +canvas.pack() |
| 21 | + |
| 22 | +def moveit(): |
| 23 | + canvas.move(rect, 0, 2) |
| 24 | + |
| 25 | +b = tk.Button(window, text='move', command=moveit).pack() |
| 26 | + |
| 27 | + |
| 28 | +window.mainloop() |
| 29 | + |
0 commit comments