Skip to content
This repository was archived by the owner on Jun 8, 2024. It is now read-only.

Commit f1f2179

Browse files
authored
add Screenshot script (#164)
* Add text-to-sound script * fix failed check is about blank * add screenshot script * fix failed issues from screenshot.py * fix again sorry
1 parent d0bf552 commit f1f2179

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

screenshot/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Screenshot
2+
3+
Screenshot is a Python script for taking a screenshot.
4+
5+
## Library used
6+
- tkinter
7+
- PyAutoGUI
8+
9+
## Setup
10+
11+
Install the packages listed in `requirements.txt` using `pip`
12+
13+
```bash
14+
pip install -r requirements.txt
15+
```
16+
17+
## Usage
18+
19+
```bash
20+
cd screenshot
21+
python screenshot.py
22+
```

screenshot/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PyAutoGUI==0.9.50
2+
tk==0.1.0

screenshot/screenshot.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import tkinter as tk
2+
from tkinter import messagebox
3+
import pyautogui
4+
import os
5+
6+
7+
root = tk.Tk()
8+
time = tk.IntVar()
9+
time.set(3)
10+
11+
12+
def take_shot():
13+
timeleft = time.get()
14+
if timeleft > 0:
15+
timeleft -= 1
16+
time.set(timeleft)
17+
root.after(1000, take_shot)
18+
else :
19+
s = pyautogui.screenshot()
20+
# Save a screenshot on current working directory
21+
s.save(os.getcwd() + "shot.png")
22+
messagebox.showinfo("Screenshot", "Screenshot saved!")
23+
time.set(3)
24+
25+
26+
L = tk.Label(root, textvariable=time, fg="blue")
27+
L.pack()
28+
29+
b = tk.Button(root, text="Take Screenshot 3 secs", command=take_shot)
30+
b.pack()
31+
32+
root.mainloop()

0 commit comments

Comments
 (0)