In this video I’ll show you how to take screenshots from your Tkinter app.

We’ll use the mss library to do the heavy lifting here and take the screenshots.

You can set different monitors you would like to take screenshots from if you have more than one.

Python Code: shot.py
(Github Code)

from tkinter import *
from mss import mss

root = Tk()
root.title('Codemy.com - Screen Shot')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x200")

def shot():
	with mss() as sct:
		# Designate the filename
		filename = sct.shot(mon=2, output="output.png")	

		# Confirm message
		my_label.config(text="Screen Shot Has Been Saved!")

my_button = Button(root, text="Take A Screenshot!", font=("Helvetica", 24), command=shot)
my_button.pack(pady=40)

my_label = Label(root, text="")
my_label.pack(pady=10)


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...