screenshot taker code example

Example: screen shot taketr

from tkinter.filedialog import *
import pyautogui
import tkinter

root = Tk()
root.title('Take A Screenshot')
root.geometry('300x300')

canvas = tkinter.Canvas(root, width=300, height=300)
canvas.pack()


def takeScreenshot():
    img = pyautogui.screenshot()
    savePath = asksaveasfilename()
    if not ('.png' in savePath): savePath = savePath + '.png'
    img.save(savePath)

button = tkinter.Button(text="Take a Screenschot", command=takeScreenshot, font=10)
canvas.create_window(150, 150, window=button)

root.mainloop()