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,