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:
And you just use them by slapping them into your Button code:
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
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()