In this video I’ll show you how to use Bitmaps on your Buttons for Tkinter and Python.

You can use your own bitmap images, but there are nine bitmaps that come with Tkinter that you can use. They are:

error
gray75
gray50
gray12
hourglass
info
questhead
question
warning

And you just use them by slapping them into your Button code:

Button(root, bitmap=”error)

And that’s all there is to it! You can use your own .xbm files if you want, but I generally recommend not doing that. Instead just use a png image file like we’ve done in other videos.

Python Code: bitmap.py
(Github Code)

from tkinter import *

root = Tk()
root.title("Bitmaps")
root.geometry("300x900")
root.iconbitmap('c:/guis/exe/codemy.ico')

'''
error
gray75
gray50
gray12
hourglass
info
questhead
question
warning
'''
list = ["error",
"gray75",
"gray50",
"gray12",
"hourglass",
"info",
"questhead",
"question",
"warning"]

for map in list:
	Button(root, bitmap=map, width=50, height=50, fg="darkblue").pack(pady=20)



root.mainloop()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...