
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use Bitmap Images in Button in Tkinter
In Tkinter, we can create and customize buttons using images. These images can be uploaded by using the Python PhotoImage(file) function.
However, PhotoImage() supports only a few image types such as PNG, PPM, and GIF. In addition, we can create buttons using BitMap images too. A bitmap image is nothing but a set of dots aligned in a matrix which represents a pixel of the image. The following types of bitmap attributes are available in Tkinter,
"error"
"gray75"
"gray50"
"gray25"
"gray12"
"hourglass"
"info"
"questhead"
"question"
"warning"
Example
from tkinter import * #Create an instance of tkinter frame win = Tk() win.geometry("700x300") win.resizable(0,0) Button(win, relief=RAISED, bitmap="info").pack(pady=10) Button(win, relief=RAISED, bitmap="gray50").pack(pady=10) Button(win, relief=RAISED, bitmap="gray25").pack(pady=10) Button(win, relief=RAISED, bitmap="gray12").pack(pady=10) Button(win, relief=RAISED, bitmap="questhead").pack(pady=10) win.mainloop()
Output
Running the above code will create bitmap buttons as the following,
Advertisements