How to Create bitmap image in label tkinter


Tkinter is one of the most common Interface of Python  GUI(Graphical User Interface). Bitmap is used to display an image in the label. The Bitmap Image class provides a simple image class, for monochrome (two-color) images. This class can be used to display bitmap images in labels, buttons, canvases, and text widgets. bitmap is an array of binary data representing the values of pixels in an image. Bitmap is used to set the bitmap to the graphical object specified so that, the label can represent the graphics instead of text.
To Create a bitmap image it can take the following values..
1) error
2) gray75
3) gray50
4) gray25
5) gray12
6) hourglass
7) info
8) questhead
9) question
10) warning

Example: 

from tkinter import *

my_window = Tk()
my_window.title("Bitmap Using Label")
my_window.geometry("800x520+450+86")
my_window.config(bg="#8EE5EE")

lbl1 = Label(my_window,font=("times", 20, "bold"),bitmap="gray75", width=80, height=40)
lbl2 = Label(my_window,font=("times", 20, "bold"),bitmap="gray50", width=80, height=40)
lbl3 = Label(my_window,font=("times", 20, "bold"),bitmap="gray25", width=80, height=40)
lbl4 = Label(my_window,font=("times", 20, "bold"),bitmap="gray12", width=80, height=40)
lbl5 = Label(my_window,font=("times", 20, "bold"),bitmap="hourglass", width=80, height=40)
lbl6 = Label(my_window,font=("times", 20, "bold"),bitmap="info", width=80, height=40)
lbl7 = Label(my_window,font=("times", 20, "bold"),bitmap="questhead", width=80, height=40)
lbl8 = Label(my_window,font=("times", 20, "bold"),bitmap="question", width=80, height=40)
lbl9 = Label(my_window,font=("times", 20, "bold"),bitmap="warning", width=80, height=40)

lbl1.pack(pady=10)
lbl2.pack(pady=10)
lbl3.pack(pady=5)
lbl4.pack(pady=5)
lbl5.pack(pady=5)
lbl6.pack(pady=5)
lbl7.pack(pady=5)
lbl8.pack(pady=5)
lbl9.pack(pady=5)

my_window.mainloop()



Write Down Code Your Code Editor. To show Your Output. If Use Pycharm Press Shift+F10 and Show Your Output.


Enjoy................






Post a Comment

Previous Post Next Post