Create a Screenshot Button using Python Tkinter

Screenshoot Button

Hello coders we create this project with Python Tkinter 

  •   In this project we create a screenshot  programm.

Libraries used-

  >>Tkinter(for GUI)

  >>pyautogui(for screenshot)

Step to create GUI-

  • Install Tkinter using pip install
  • Import Tkinter
  • Create the main window
  • Import png button

Algorithm-

  • Create window and import button png
  • Use pyautogui to take screenshot in function
  • Use tkinter filedialog to ask to save file
  • Create button and add command    
#importing Libraries============================================
from tkinter import *
import pyautogui
from tkinter.filedialog import asksaveasfilename as ask

root = Tk()

#importing image================================================
press_btn = PhotoImage(file='btn copy.png')#use your button png name

#function definned==============================================
def action():
    myScreenshot = pyautogui.screenshot()
    file=ask(initialfile="Untitled.png",defaultextension='.png')
    myScreenshot.save(file)

#creating button================================================
btn  = Button(root,image=press_btn,borderwidth=0,command=action)
btn.pack(pady=1)


mainloop()

Output:

Here if you have any doubt feel free to connect us: +91-7982108418

Write a comment