forked from shokobata/WhatPulse-Alternative
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.py
54 lines (41 loc) · 1.99 KB
/
reset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Last modified: 4-1-2023
import os
import json
import PySimpleGUI as sg
from datetime import date
from string import ascii_lowercase
def DailyShowCase(): # CONTINUE: This function is currently useless. I plan to use it gain later on
"""read data from DailyData.json and display it in a popup window"""
with open("DailyData.json") as f: #
Data = json.load(f)
Letters = Data["Today's Letters"]
SortedLetters = dict(sorted(Letters.items(), key=lambda val: val[1], reverse=True))
FinalString = ("\n".join(f"{k.upper()}: {v}" for k, v in SortedLetters.items()))
sg.PopupScrolled("Today's\nKeystrokes", f"{FinalString}", title="Keystroke Statistics",
background_color="grey", grab_anywhere=True, no_titlebar=True, font=16, auto_close=True,
auto_close_duration=30, size=(12, 15))
def ShowCase(): # CONTINUE: This function is currently useless. I plan to use it gain later on
"""read data from Data.json and display it in a popup window"""
with open("Data.json") as File:
Data = json.load(File)
Letters = Data["Letters"]
SortedLetters = dict(sorted(Letters.items(), key=lambda val: val[1], reverse=True))
FinalString = "\n".join(f"{k.upper()}: {v}" for k, v in SortedLetters.items())
sg.PopupScrolled("Lifetime\nKeystrokes\n", f"{FinalString}", title="Keystroke Statistics",
background_color="grey", grab_anywhere=True, no_titlebar=True, font=16, auto_close=True,
auto_close_duration=30, size=(12, 15))
def ResetDailyData():
"""resets all daily values"""
newData = {
"Today's LClicks": 0,
"Today's RClicks": 0,
"Today's MClicks": 0,
"Today's Scrolls": 0,
"Today's KeyPress": 0,
"Today's Letters": {},
"Date": str(date.today())
}
for letter in ascii_lowercase:
newData["Today's Letters"][letter] = 0
with open('DailyData.json', 'w', encoding='utf8') as f:
json.dump(newData, f, indent=4)