Skip to content
Related Articles

Related Articles

How do you create a Button on a tkinter Canvas?

View Discussion
Improve Article
Save Article
  • Last Updated : 03 Jan, 2021

In this article, we will see how to create a button on a Tkinter Canvas.

The Canvas widget display various graphics on the application. It can be used to draw simple shapes to complicated graphs. We can also display various kinds of custom widgets according to our needs.

 It is used trigger any function which is presented in the code

Intro to code :

In this we try to create button on canvas widget. Firstly make canvas then place the button on the canvas.


C = Canvas(root, height, width, bd, bg)


button = Button ( root,height,width,bg,command)

Steps :

  1. Import tkinter from
  2. Then define the window size and other requirements.
  3. First create canvas from the above give syntax.
  4. With the help of place function in tkinter place the button.


# import everything from tkinter module
from tkinter import *
root = Tk()
title = Label(root, text="Geeksforgeeks", bg="green", font=("bold", 30))
c = Canvas(root, width=330, height=200, bg="red"), y=50)
btn = Button(root, text='Welcome to Tkinter!', width=40,
             height=5, bd='10', command=root.destroy), y=100)


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!