Skip to content

Commit 4865c40

Browse files
committed
fdvoid0
0 parents  commit 4865c40

File tree

1,774 files changed

+914756
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,774 files changed

+914756
-0
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.css linguist-language=python
2+
*.less linguist-language=python
3+
*.js linguist-language=python
4+
*.html linguist-language=python
5+
. filter=lfs diff=lfs merge=lfs -text

.vscode/settings.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"python.pythonPath": "d:\\Anaconda3\\python.exe",
3+
"files.associations": {
4+
"cmath": "cpp",
5+
"cstddef": "cpp",
6+
"cstdint": "cpp",
7+
"cstdio": "cpp",
8+
"cstdlib": "cpp",
9+
"cstring": "cpp",
10+
"cwchar": "cpp",
11+
"exception": "cpp",
12+
"initializer_list": "cpp",
13+
"ios": "cpp",
14+
"iosfwd": "cpp",
15+
"iostream": "cpp",
16+
"istream": "cpp",
17+
"limits": "cpp",
18+
"memory": "cpp",
19+
"new": "cpp",
20+
"ostream": "cpp",
21+
"stdexcept": "cpp",
22+
"streambuf": "cpp",
23+
"system_error": "cpp",
24+
"type_traits": "cpp",
25+
"typeinfo": "cpp",
26+
"utility": "cpp",
27+
"xfacet": "cpp",
28+
"xiosbase": "cpp",
29+
"xlocale": "cpp",
30+
"xlocinfo": "cpp",
31+
"xlocnum": "cpp",
32+
"xmemory": "cpp",
33+
"xmemory0": "cpp",
34+
"xstddef": "cpp",
35+
"xstring": "cpp",
36+
"xtr1common": "cpp",
37+
"xutility": "cpp",
38+
"string.h": "c"
39+
},
40+
"git.ignoreLimitWarning": true,
41+
"python.analysis.typeCheckingMode": "basic"
42+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import PySimpleGUI as sg
2+
3+
layout = [
4+
[
5+
sg.Input(key='-INPUT-'),
6+
sg.Spin(['km to mile', 'kg to pound', 'sec to min'], key='-UNITS-'),
7+
sg.Button('Convert', key='-CONVERT-')
8+
],
9+
[sg.Text('Output', key='-OUTPUT-')]
10+
]
11+
12+
window = sg.Window('Converter', layout)
13+
14+
while True:
15+
event, values = window.read()
16+
if event == sg.WIN_CLOSED:
17+
break
18+
19+
if event == '-CONVERT-':
20+
input_value = values['-INPUT-']
21+
if input_value.isnumeric():
22+
match values['-UNITS-']:
23+
case 'km to mile':
24+
output = round(float(input_value) * 0.6214, 2)
25+
output_string = f'{input_value} km are {output} miles.'
26+
case 'kg to pound':
27+
output = round(float(input_value) * 2.20462, 2)
28+
output_string = f'{input_value} kg are {output} pounds.'
29+
case 'sec to min':
30+
output = round(float(input_value) / 60, 2)
31+
output_string = f'{input_value} seconds are {output} minutes.'
32+
33+
window['-OUTPUT-'].update(output_string)
34+
else:
35+
window['-OUTPUT-'].update("please enter a number...")
36+
37+
window.close()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import PySimpleGUI as sg
2+
from bs4 import BeautifulSoup as bs
3+
import requests
4+
5+
def get_weather_data(location):
6+
url = f"https://www.google.com/search?q=weather+{location.replace(' ', '')}"
7+
session = requests.Session()
8+
session.headers['User-Agent'] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
9+
html = session.get(url)
10+
11+
soup = bs(html.text, 'html.parser')
12+
name = soup.find('div', attrs={'id':'wob_loc'}).text
13+
time = soup.find('div', attrs={'id':'wob_dts'}).text
14+
weather = soup.find('span', attrs={'id':'wob_dc'}).text
15+
temp = soup.find('span', attrs={'id':'wob_tm'}).text
16+
return name, time, weather, temp
17+
18+
19+
sg.theme('reddit')
20+
image_col = sg.Column([[sg.Image(key='-IMAGE-', background_color='#FFFFFF')]])
21+
info_col = sg.Column([
22+
[sg.Text('', key='-LOCATION-', font='Calibri 30', background_color='#FF0000', pad=0, visible=False)],
23+
[sg.Text('', key='-TIME-', font='Calibri 16', background_color='#000000', text_color='#FFFFFF', pad=0, visible=False)],
24+
[sg.Text('', key='-TEMP-', font='Calibri 16', pad=(0,10), background_color='#FFFFFF', text_color='#000000', justification='center', visible=False)]
25+
])
26+
27+
layout = [
28+
[sg.Input(expand_x=True, key='-INPUT-'), sg.Button('Enter', button_color='#000000', border_width=0)],
29+
[image_col, info_col]
30+
]
31+
32+
window = sg.Window('Weather', layout)
33+
34+
while True:
35+
event, values = window.read()
36+
if event == sg.WIN_CLOSED:
37+
break
38+
39+
if event == 'Enter':
40+
name, time, weather, temp = get_weather_data(values['-INPUT-'])
41+
window['-LOCATION-'].update(name, visible=True)
42+
window['-TIME-'].update(time.split(' ')[0], visible=True)
43+
window['-TEMP-'].update(f'{temp} \u2103 ({weather})', visible=True)
44+
window['-IMAGE-'].update('snow.png')
45+
46+
window.close()
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import PySimpleGUI as sg
2+
import cv2
3+
4+
layout=[
5+
[sg.Image(key='-IMAGE-')],
6+
[sg.Text('People in picture: 0', key='-TEXT-', expand_x=True, justification='c')]
7+
]
8+
9+
window = sg.Window('Face Detector', layout)
10+
11+
# get video
12+
video = cv2.VideoCapture(0)
13+
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
14+
15+
while True:
16+
event, values = window.read(timeout=0)
17+
if event == sg.WIN_CLOSED:
18+
break
19+
20+
_, frame = video.read()
21+
gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
22+
faces = face_cascade.detectMultiScale(
23+
gray,
24+
scaleFactor=1.3,
25+
minNeighbors=7,
26+
minSize=(50,50))
27+
28+
# draw the rectangles
29+
for (x,y,w,h) in faces:
30+
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,0),2)
31+
32+
# update the image
33+
imgbytes = cv2.imencode('.png', frame)[1].tobytes()
34+
window['-IMAGE-'].update(data=imgbytes)
35+
36+
# update the text
37+
window['-TEXT-'].update(f'People in picture: {len(faces)}')
38+
39+
window.close()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import PySimpleGUI as sg
2+
3+
print(sg.Window('', [[sg.Input(), sg.Button('Ok'), sg.Button('Cancel')]]).read())
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import PySimpleGUI as sg
2+
3+
def create_window(theme):
4+
sg.theme(theme)
5+
sg.set_options(font='Franklin 14', button_element_size=(6,3))
6+
button_size = (6,3)
7+
layout = [
8+
[sg.Text(
9+
'',
10+
font='Franklin 26',
11+
justification='right',
12+
expand_x=True,
13+
pad=(10,20),
14+
right_click_menu=theme_menu,
15+
key='-TEXT-')
16+
],
17+
# [sg.Push(), sg.Text('output', font='Franklin 26')],
18+
[sg.Button('Clear', expand_x=True), sg.Button('Enter', expand_x=True)],
19+
[sg.Button(7, size=button_size), sg.Button(8, size=button_size), sg.Button(9, size=button_size), sg.Button('*', size=button_size)],
20+
[sg.Button(4, size=button_size), sg.Button(5, size=button_size), sg.Button(6, size=button_size), sg.Button('/', size=button_size)],
21+
[sg.Button(1, size=button_size), sg.Button(2, size=button_size), sg.Button(3, size=button_size), sg.Button('-', size=button_size)],
22+
[sg.Button(0, expand_x=True), sg.Button('.', size=button_size), sg.Button('+', size=button_size)]
23+
]
24+
25+
return sg.Window('Calculator', layout)
26+
27+
theme_menu = ['menu', ['LightGrey1', 'dark', 'DarkGray8', 'random']]
28+
window = create_window('dark')
29+
30+
current_num = []
31+
full_operation = []
32+
33+
while True:
34+
event, values = window.read()
35+
if event == sg.WIN_CLOSED:
36+
break
37+
38+
if event in theme_menu[1]:
39+
window.close()
40+
window = create_window(event)
41+
42+
if event in ['0','1','2','3','4','5','6','7','8','9','.']:
43+
current_num.append(event)
44+
num_string = ''.join(current_num)
45+
window['-TEXT-'].update(num_string)
46+
47+
if event in ['+','-','/','*']:
48+
full_operation.append(''.join(current_num))
49+
current_num = []
50+
full_operation.append(event)
51+
window['-TEXT-'].update('')
52+
53+
if event == 'Enter':
54+
full_operation.append(''.join(current_num))
55+
result = eval(' '.join(full_operation))
56+
window['-TEXT-'].update(result)
57+
full_operation = []
58+
59+
if event == 'Clear':
60+
current_num = []
61+
full_operation = []
62+
window['-TEXT-'].update('')
63+
64+
window.close()
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import PySimpleGUI as sg
2+
from time import time
3+
4+
def create_window():
5+
sg.theme('black')
6+
layout = [
7+
[sg.Push(), sg.Image('cross.png', pad=0, enable_events=True, key='-CLOSE-')],
8+
[sg.VPush()],
9+
[sg.Text('', font='Young 50', key='-TIME-')],
10+
[
11+
sg.Button('Start', button_color=('#FFFFFF','#FF0000'), border_width=0, key='-STARTSTOP-'),
12+
sg.Button('Lap', button_color=('#FFFFFF','#FF0000'), border_width=0, key='-LAP-', visible=False)
13+
],
14+
[sg.Column([[]], key='-LAPS-')],
15+
[sg.VPush()]
16+
]
17+
18+
return sg.Window(
19+
'stopwatch',
20+
layout,
21+
size=(300,300),
22+
no_titlebar=True,
23+
element_justification='center')
24+
25+
window = create_window()
26+
start_time = 0
27+
active = False
28+
lap_amount = 1
29+
30+
while True:
31+
event, values = window.read(timeout=10)
32+
if event in (sg.WIN_CLOSED, '-CLOSE-'):
33+
break
34+
35+
if event == '-STARTSTOP-':
36+
if active:
37+
# from active to stop
38+
active = False
39+
window['-STARTSTOP-'].update('Reset')
40+
window['-LAP-'].update(visible = False)
41+
else:
42+
# from stop to reset
43+
if start_time > 0:
44+
window.close()
45+
window = create_window()
46+
start_time = 0
47+
lap_amount = 1
48+
# from start to active
49+
else:
50+
start_time = time()
51+
active = True
52+
window['-STARTSTOP-'].update('Stop')
53+
window['-LAP-'].update(visible = True)
54+
55+
if active:
56+
elapsed_time = round(time() - start_time, 1)
57+
window['-TIME-'].update(elapsed_time)
58+
59+
if event == '-LAP-':
60+
window.extend_layout(window['-LAPS-'], [[sg.Text(lap_amount), sg.VSeparator(), sg.Text(elapsed_time)]])
61+
lap_amount += 1
62+
63+
window.close()
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from asyncore import file_dispatcher
2+
import PySimpleGUI as sg
3+
from pathlib import Path
4+
5+
smileys = [
6+
'happy', [':)', 'xD', ':D', '<3'],
7+
'sad', [':(', 'T_T'],
8+
'other', [':3']
9+
]
10+
11+
menu_layout = [
12+
['File', ['Open', 'Save', '---', 'Exit']],
13+
['Tools', ['Word Count']],
14+
['File', smileys]
15+
]
16+
17+
smiley_events = smileys[1] + smileys[3] + smileys[5]
18+
19+
sg.theme('GrayGrayGray')
20+
layout = [
21+
[sg.Menu(menu_layout)],
22+
[sg.Text('Untitled', key='-DOCNAME-')],
23+
[sg.Multiline(no_scrollbar=True, size=(40,30), key='-TEXTBOX-')]
24+
]
25+
26+
window = sg.Window('Text Editor', layout)
27+
28+
while True:
29+
event, values = window.read()
30+
if event in (sg.WIN_CLOSED, '-CLOSE-'):
31+
break
32+
33+
if event == 'Open':
34+
file_path = sg.popup_get_file('open', no_window=True)
35+
if file_path:
36+
file = Path(file_path)
37+
window['-TEXTBOX-'].update(file.read_text())
38+
window['-DOCNAME-'].update(file_path.split('/')[-1])
39+
40+
if event == 'Save':
41+
file_path = sg.popup_get_file('Save as', no_window=True, save_as=True) + '.txt'
42+
file = Path(file_path)
43+
file.write_text(values['-TEXTBOX-'])
44+
window['-DOCNAME-'].update(file_path.split('/')[-1])
45+
46+
if event == 'Word Count':
47+
full_text = values['-TEXTBOX-']
48+
clean_text = full_text.replace('\n',' ').split(' ')
49+
word_count = len(clean_text)
50+
char_count = len(''.join(clean_text))
51+
sg.popup(f'words {word_count}\ncharacters: {char_count}')
52+
53+
if event in smiley_events:
54+
current_text = values['-TEXTBOX-']
55+
new_text = current_text + ' ' + event
56+
window['-TEXTBOX-'].update(new_text)
57+
58+
window.close()

0 commit comments

Comments
 (0)