How to Create bitmap image in label tkinter using for loop 


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 Image Using for loop ")
my_window.geometry("800x520+450+86")
my_window.config(bg="#8EE5EE")

list = ["gray75",
        "gray50",
"gray25",
"gray1",
"hourglass",
"info",
"questhead",
"question",
"warning"]

for btmap in list:
lbl = Label(my_window,bitmap=btmap, bg="#FFD39B", width=50, height=40)
lbl.pack(pady=10)

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

أحدث أقدم