import tkinter as tk mywindow = tk.Tk() # Set canvas size canvasName = tk.Canvas(mywindow,height=300,width=400,bg='white') canvasName.pack() #Example Shapes canvasName.create_rectangle(50,50,100,200, fill="red", width=2) canvasName.create_line(200, 200, 300, 300, fill="black",width="13") canvasName.create_arc(20, 20, 300, 100, fill="cyan") canvasName.create_text(100,100,text="We can draw") canvasName.create_oval(10, 10, 80, 80, outline="#f12", fill="#1f2", width=2) mywindow.mainloop()
Related Sections
Python - Learn the python from the basics up. This fast track example code course will get you creating powerful python programs in no time.Tkinter - Learn the key features of the tkinter to allow you to create user interfaces for your python programs.
Must Read Articles
Tkinter - Combo Box - This is a short example showing how to use combo boxes in a GUI.Tkinter - Radio Buttons - A short example of how to create a GUI with radio buttons.
Tkinter _ Canvas - Canvas allows for a range of shapes to be plotted, such as circles, squares, lines and labels.
Tkinter - Pack vs Grid vs Place - tkinter provides flexibility in how the layout the widgets.
Pickle - The pickle library allows a program to save data in a binary file.
Python - List Comprehension - Create powerful list comprehension expressions.
Python - Generators - Learn about generator statements.
Python - Data types - The learn about the key datatypes in the python language.