Skip to content

Commit 183e560

Browse files
authored
Merge branch 'python-geeks:main' into main
2 parents a40b3fa + 123bf19 commit 183e560

File tree

5 files changed

+247
-0
lines changed

5 files changed

+247
-0
lines changed

image_downloader/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Image Downloader
2+
A simple python script to download images by providing link to the images.
3+
4+
## Modules Used
5+
6+
- requests
7+
- pillow
8+
- io
9+
- os
10+
11+
## Requirements
12+
13+
- Run the following in the directory containing the script files.
14+
15+
```bash
16+
pip install requests pillow
17+
```
18+
19+
- Then run the below command
20+
21+
```bash
22+
python image_downloader.py
23+
```

image_downloader/main.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import requests
2+
from PIL import Image
3+
from io import BytesIO
4+
import os
5+
6+
download_path = os.path.dirname(os.path.abspath(__file__))
7+
count = 1
8+
while True:
9+
url = input("Enter Image URL: ")
10+
try:
11+
res = requests.get(url)
12+
except Exception:
13+
print("Invalid URL / Can't Access The URL")
14+
continue
15+
16+
img = Image.open(BytesIO(res.content))
17+
format = img.format
18+
imgLoc = os.path.join(download_path, f"{count}.{format.lower()}")
19+
img = img.save(imgLoc, format=format.upper())
20+
print(f"Image Downloaded: {imgLoc}")
21+
count += 1

image_downloader/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pillow
2+
requests

pomodoro_timer/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# GUI Pomodoro Timer
2+
3+
- A pomodoro timer with customisable time options.
4+
- The user can select the pre-defined timer options.
5+
- Or the user can enter custome work/break periods
6+
7+
## Usage
8+
9+
- Copy the contents of the folder into your desired location
10+
- Execute the script `python pomodoro_timer.py`
11+
- No packages to install.
12+
13+
### Instructions
14+
This application is intuitive and easy to use :-
15+
- Select the predefined pomodoro options
16+
- Or enter your own work/break timings
17+
- Work until the work timer ends
18+
- Take a break until break timer ends
19+
- This will go on for 4 cycles in total
20+
21+
22+
## Authors
23+
24+
- [@SwarajBaral](https://www.github.com/SwarajBaral)
25+

pomodoro_timer/pomodoro_timer.py

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
import ctypes
2+
import time
3+
from tkinter import Button, Entry, Frame, Label, Tk
4+
from tkinter.constants import BOTTOM, FLAT, LEFT
5+
from tkinter.font import BOLD
6+
import threading
7+
import winsound
8+
9+
ctypes.windll.shcore.SetProcessDpiAwareness(True)
10+
11+
root = Tk()
12+
root.config(bg="Salmon")
13+
root.geometry('600x500')
14+
root.title("Pomodoro Timer")
15+
root.resizable(0, 0)
16+
17+
POMO_OPTIONS = {
18+
0: (25, 5),
19+
1: (20, 10),
20+
}
21+
22+
23+
def user_start():
24+
custom_work = int(user_input_work.get())
25+
custom_break = int(user_input_break.get())
26+
start_timer_params = (custom_work, custom_break)
27+
return threading.Thread(
28+
target=start_timer, args=[start_timer_params]).start()
29+
30+
31+
def today():
32+
day = time.strftime("%a")
33+
hour = time.strftime("%I")
34+
minutes = time.strftime("%M")
35+
ampm = time.strftime("%p")
36+
date_label.config(text=f"{day} {hour}:{minutes} {ampm}")
37+
date_label.after(1000, today)
38+
39+
40+
def reset():
41+
title_label.config(text="Focus...")
42+
timer_label.config(text="Timer Here")
43+
root.geometry("600x500")
44+
button_frame.pack(pady=10)
45+
cycle_label.pack_forget()
46+
input_frame.pack(pady=20)
47+
instruction_label.pack()
48+
return
49+
50+
51+
def start_timer(options, cycle_limit=5):
52+
root.geometry("600x250")
53+
cycles = 1
54+
_work = int(options[0] * 60)
55+
_break = int(options[1] * 60)
56+
button_frame.pack_forget()
57+
input_frame.pack_forget()
58+
instruction_label.pack_forget()
59+
while cycles < cycle_limit:
60+
cycle_label.config(text=f"Cycle no - {cycles}")
61+
cycle_label.pack()
62+
temp_work = _work
63+
temp_break = _break
64+
while temp_work:
65+
title_label.config(text="You should be working now.")
66+
minutes, seconds = divmod(temp_work, 60)
67+
timer_label.config(text=f"{minutes}:{seconds}")
68+
root.update_idletasks()
69+
time.sleep(1)
70+
temp_work -= 1
71+
winsound.Beep(323, 250)
72+
winsound.Beep(583, 250)
73+
while temp_break:
74+
title_label.config(text="You should be taking a break now.")
75+
minutes, seconds = divmod(temp_break, 60)
76+
timer_label.config(text=f"{minutes}:{seconds}")
77+
root.update_idletasks()
78+
time.sleep(1)
79+
temp_break -= 1
80+
winsound.Beep(523, 250)
81+
winsound.Beep(783, 250)
82+
cycles += 1
83+
84+
reset()
85+
return
86+
87+
88+
# Title
89+
title_label = Label(root, text="Focus...",
90+
font=("MV Boli", 20, BOLD),
91+
bg="Salmon")
92+
title_label.pack()
93+
94+
# Cycle Number
95+
cycle_label = Label(root, font=("Consolas", 20, BOLD),
96+
bg="Salmon")
97+
98+
# Pomodoro Timer
99+
timer_label = Label(root, text="Timer here",
100+
bg="black", fg="green", font=("Consolas", 32),
101+
width=10)
102+
timer_label.pack(pady=20)
103+
104+
# Pomodoro Cycle Button Options
105+
button_frame = Frame(root, bg="salmon")
106+
button_frame.pack(pady=10)
107+
108+
pom_one = Button(button_frame, text="25/5 Cycle", font="Helvetica 12",
109+
height=1, width=12,
110+
command=lambda: threading.Thread(
111+
target=start_timer, args=[POMO_OPTIONS[0]]
112+
).start()
113+
)
114+
pom_one.grid(row=0, column=0, padx=5)
115+
pom_two = Button(button_frame, text="20/10 Cycle", font="Helvetica 12",
116+
height=1, width=12,
117+
command=lambda: threading.Thread(
118+
target=start_timer, args=[POMO_OPTIONS[1]]
119+
).start()
120+
)
121+
pom_two.grid(row=0, column=1)
122+
123+
# User input time options
124+
input_frame = Frame(root, bg="salmon")
125+
input_frame.pack(pady=20)
126+
127+
custom_label = Label(
128+
input_frame, text="Enter Custom work/break", bg="salmon", font="Serif 10")
129+
custom_label.grid(row=0, column=0, columnspan=2)
130+
131+
input_label_work = Label(input_frame, text="Work (in mins)",
132+
bg="salmon", font="Serif 10")
133+
input_label_break = Label(input_frame, text="Break (in mins)",
134+
bg="salmon", font="Serif 10")
135+
136+
input_label_work.grid(row=2, column=0)
137+
input_label_break.grid(row=2, column=1)
138+
139+
user_input_work = Entry(input_frame, font=(
140+
"Sans Serif", 12), relief=FLAT, width=10)
141+
user_input_break = Entry(input_frame, font=(
142+
"Sans Serif", 12), relief=FLAT, width=10)
143+
144+
user_input_work.grid(row=1, column=0)
145+
user_input_break.grid(row=1, column=1, padx=10)
146+
147+
user_input_start = Button(input_frame, text="Start",
148+
font=("Sans Serif", 8),
149+
relief=FLAT, command=user_start)
150+
user_input_start.grid(row=1, column=2)
151+
152+
# Date time label
153+
date_label = Label(root, text="Datetime:",
154+
font=("Consolas", 14), bg="salmon")
155+
date_label.pack(side=BOTTOM)
156+
157+
158+
# Instruction Label
159+
instruction_label = Label(
160+
root,
161+
text='''
162+
• Select the predefined pomodoro options
163+
• Or enter your own work/break timings
164+
• Work until the work timer ends
165+
• Take a break until break timer ends
166+
• This will go on for 4 cycles in total
167+
''',
168+
font="Serif 12 bold",
169+
justify=LEFT,
170+
bg="salmon"
171+
)
172+
instruction_label.pack()
173+
174+
if __name__ == "__main__":
175+
threading.Thread(target=today).start()
176+
root.mainloop()

0 commit comments

Comments
 (0)