Take Screenshot
In this article we are going to build a Screenshot Taker
with the help of Tkinter (to build GUI),PyAutoGUI(perform the actual fuction).Using
python it is very easy to take screenshot.PyAutoGUI tool provide the simplest
method to capture the screen.
Tkinter :-
tkinter is a GUI library of python for building a
Graphical Interface for users. However there
are alot of other packages that provide the GUI interface in python ,But
tkinter is the most commonly used library.It provide the powerful interface to
the Tk GUI toolkit. In this article we
are going to build a Screenshot taker with the help of Tkinter.
There are two methods to import tkinter module:
1.import tkinter
2.from tkinter import *
PyAutoGUI:-
PyAutoGUI is a cross-platform GUI Python module for human
being to manage and control the mouse
& keyboard via a python script .This python script enables the automation
of tasks.
PyAutoGUI has many tools like:
1.simulating mouse movements, button clicks, and scrolling the
mouse wheel.
2.taking
screen shots
3.automating
task
Installation:
PyAutoGUI is a platform independent , so it is fairly
easy to install it on all the operating systems. You can install it by simple
run the following command into your Command prompt and the installation will be
done.
1.On
Windows:-There is no dependency on windows to install it.Simply
run the command that is given below:
pip
install pyautogui
2.On
Mac:-In Mac operating system you need to install two module first then you can
install PyAutoGUI.Run the following commands.
pip3 install pyobjc-core
pip3 install pyobjc
pip3 install pyautogui
3.On Linux:-For linux there is only a single dependency that
is python-3 xlib. First install the it then install pyautogui. Follow the given
below commands to install
pip3
install python3-xlib
pip3
install pyautogui
Here
is the simplest method to take screen shot using python library PyAutoGUI.
Steps:
import tkinter as tk
import pyautogui as pg
root=tk.Tk()
root.title("Screenshot GUI")
root.geometry('500x500')
def screenshot():
screenshot=pg.screenshot()
screenshot.save("C:/screenshot.png")
capture=tk.Button(root,text="Capture",command=screenshot)
capture.grid(row=3,column=3)
root.mainloop()
Learn more:
Python Mini Projects
1 Comments
haecrintio-wa Sherry Adkins Download
ReplyDeletelaikingpharbung