How to show multiple Canvases at the same time in Tkinter?


The Canvas widget is one of the versatile widgets in Tkinter which is used to create illustrations, draw shapes, arcs, images, and other complex layouts in an application. To create a Canvas widget, you'll need to create a constructor of canvas(root, **options).

You can use the factory functions to create text, images, arcs and define other shapes in the canvas. In some cases, if you want to create another canvas using the same canvas to keep the application workflow consistent, then you can create a button to call an event that creates another canvas.

To understand this, let us create a canvas and a button to open another canvas to update the primary canvas widget.


# Import required libraries
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter window
win = Tk()

# Create an instance of style class

def open_new_win():
   canvas1=Canvas(canvas, height=180, width=100, bg="#aaaffe")
   Label(canvas1, text="You can modify this text", font='Helvetica 18 bold').pack()

# Create a canvas widget
canvas=Canvas(win, height=400, width=300)

# Create a button widget
button=ttk.Button(canvas, text="Open Window", command=open_new_win)



Running the above code will display a window with a button to open another canvas window.

When you click the button, it will display a message on the primary canvas window.

Updated on 22-Dec-2021 10:47:51