Welcome folks today in this blog post we will be adding the bitmap images buttons in window using tkinter in python. All the full source code of the application is shown below.
Get Started
In order to get started you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# Import Module from tkinter import * # Create Objects root = Tk() # Buttons Button(root, relief=RAISED, bitmap="error").pack(pady=10) Button(root, relief=RAISED, bitmap="hourglass").pack(pady=10) Button(root, relief=RAISED, bitmap="info").pack(pady=10) Button(root, relief=RAISED, bitmap="question").pack(pady=10) Button(root, relief=RAISED, bitmap="warning").pack(pady=10) Button(root, relief=RAISED, bitmap="gray75").pack(pady=10) Button(root, relief=RAISED, bitmap="gray50").pack(pady=10) Button(root, relief=RAISED, bitmap="gray25").pack(pady=10) Button(root, relief=RAISED, bitmap="gray12").pack(pady=10) Button(root, relief=RAISED, bitmap="questhead").pack(pady=10) # Execute Tkinter root.mainloop() |
And also in the above code we are initializing the tkinter
constructor. And after that we are adding the different kinds of bitmap images such as error
and hourglass
. These are the different names to the bitmap images. And also we are adding the bitmap image buttons inside the canvas using the pack()
method. And then we are also adding the padding in y direction.