[source code] Python GUI with Tkinter - 13 - Shapes and Graphics

+1 Bucky Roberts · September 16, 2014

from tkinter import *

root = Tk()

canvas = Canvas(root, width=200, height=100)
canvas.pack()

blackLine = canvas.create_line(0, 0, 200, 50)
redLine = canvas.create_line(0, 100, 200, 50, fill="red")
greenBox = canvas.create_rectangle(25, 25, 130, 60, fill="green")

canvas.delete(redLine)
canvas.delete(ALL)

root.mainloop()

Post a Reply

Replies

Oldest  Newest  Rating
+1 Wayne [Im That Damn Good] Leyden · September 16, 2014
when you created the box the second and third arguments are the end points of the shape not the size.
0 Bucky Roberts · September 17, 2014
Embarrassing 
  • 1

Python

106,994 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator