- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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() win.geometry("700x350") # Create an instance of style class style=ttk.Style(win) def open_new_win(): top=Toplevel(win) canvas1=Canvas(canvas, height=180, width=100, bg="#aaaffe") canvas1.pack() Label(canvas1, text="You can modify this text", font='Helvetica 18 bold').pack() # Create a canvas widget canvas=Canvas(win, height=400, width=300) canvas.pack() # Create a button widget button=ttk.Button(canvas, text="Open Window", command=open_new_win) button.pack(pady=30) win.mainloop()
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.
- Related Articles
- How to select at the same time from two Tkinter Listbox?
- Multiple data input at the same time in MySQL?
- How to identify multiple elements at the same time in Selenium with python?
- What are the best tricks to manage multiple tasks at the same time?
- How to add a number to a current value in MySQL (multiple times at the same time)?
- How to catch many exceptions at the same time in Kotlin?
- How to extend and implement at the same time in Kotlin?\n
- How to show webcam in TkInter Window?
- How to use Boto3 to get the details of multiple triggers at a time?
- How can one believe in science and religion at the same time?
- How to multiple insert or batch insert at a time in MySQL query?
- How to show multiple colorbars in Matplotlib?
- How to show and hide widgets in Tkinter?
- How to show only one view at a time in Wizard in SAP UI5?
- How to use Boto3 to get the details of multiple glue jobs at a time?