Klassendefinitionen user
This commit is contained in:
parent
1ab664ef87
commit
0a39ee7f17
6
.idea/Zeiterfassung.iml
generated
6
.idea/Zeiterfassung.iml
generated
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.11 (Zeiterfassung)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -3,5 +3,5 @@
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.11" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (Zeiterfassung)" project-jdk-type="Python SDK" />
|
||||
</project>
|
Binary file not shown.
@ -1,5 +1,21 @@
|
||||
# Zeiterfassung
|
||||
# Quasi-Konsten
|
||||
# Quasi-Konstanten
|
||||
|
||||
import os
|
||||
|
||||
app_title = "Zeiterfassung"
|
||||
app_version = "0.0.0"
|
||||
app_version = ("0.0.0")
|
||||
|
||||
# Standardpfade
|
||||
scriptpath = os.path.dirname(os.path.abspath(__file__))
|
||||
userfolder = "users"
|
||||
|
||||
# Dateinamen
|
||||
|
||||
usersettingsfilename = "settings.json"
|
||||
photofilename = "photo.png"
|
||||
|
||||
# Status
|
||||
|
||||
status_in = "eingestempelt"
|
||||
status_out = "ausgestempelt"
|
23
nice_gui.py
Normal file
23
nice_gui.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Zeiterfassung
|
||||
# Nice GUI UI
|
||||
|
||||
from nicegui import ui
|
||||
from nicegui.events import ValueChangeEventArguments
|
||||
|
||||
def site_pinpad():
|
||||
|
||||
keys = [
|
||||
[ 1, 2, 3],
|
||||
[ 4, 5, 6],
|
||||
[ 7, 8, 9],
|
||||
[ "<-", 0, "OK"]
|
||||
]
|
||||
|
||||
with ui.row():
|
||||
for y, row in enumerate(keys, 1):
|
||||
for x, key in enumerate(row):
|
||||
button = ui.Button(text=keys[y][x])
|
||||
|
||||
ui.run(port=8090)
|
||||
|
||||
site_pinpad()
|
12
nicegui_test.py
Normal file
12
nicegui_test.py
Normal file
@ -0,0 +1,12 @@
|
||||
from nicegui import ui
|
||||
|
||||
def pinpad():
|
||||
|
||||
def update_time():
|
||||
string_time = strftime('%A, der %d.%m.%Y - %H:%M:%S')
|
||||
nonlocal digital_clock
|
||||
digital_clock
|
||||
digital_clock.after(1000, update_time)
|
||||
|
||||
digital_clock = ui.label()
|
||||
update_time()
|
23
ui.py
23
ui.py
@ -9,6 +9,7 @@ from time import strftime
|
||||
from definitions import app_title, app_version
|
||||
|
||||
# Pinpad
|
||||
|
||||
def win_pinpad():
|
||||
|
||||
def update_time():
|
||||
@ -19,6 +20,8 @@ def win_pinpad():
|
||||
|
||||
root = tk.Tk()
|
||||
root.title(app_title + " " + app_version)
|
||||
root.eval('tk::PlaceWindow . center')
|
||||
|
||||
# Digital clock label configuration
|
||||
digital_clock = tk.Label(root)
|
||||
digital_clock.grid(row=0, column=0, columnspan=3, padx=10, pady=10)
|
||||
@ -26,8 +29,18 @@ def win_pinpad():
|
||||
update_time()
|
||||
|
||||
# Benutzernummer
|
||||
def usernr_changed(UserNr):
|
||||
nonlocal usernr
|
||||
if len(str(usernr.get())) > 0:
|
||||
buttons["OK"].configure(state="active")
|
||||
else:
|
||||
buttons["OK"].configure(state="disabled")
|
||||
|
||||
|
||||
tk.Label(root, text="Benutzernummer:").grid(row=1, column=0)
|
||||
usernr = tk.Entry(root, width=10)
|
||||
UserNr = tk.StringVar()
|
||||
UserNr.trace("w", lambda name, index, mode, UserNr=UserNr: usernr_changed(UserNr))
|
||||
usernr = tk.Entry(root, width=10, textvariable=UserNr)
|
||||
usernr.grid(row=1,column=1)
|
||||
|
||||
# Pinpad
|
||||
@ -48,8 +61,8 @@ def win_pinpad():
|
||||
buttons["OK"].configure(state="disabled")
|
||||
|
||||
# Buttons definieren
|
||||
button_width = 5
|
||||
button_height = 2
|
||||
button_width = 7
|
||||
button_height = 3
|
||||
pinframe = tk.Frame(root)
|
||||
pinframe.grid(row=2, column=0, columnspan=3, padx=10, pady=10)
|
||||
buttons = { }
|
||||
@ -69,7 +82,11 @@ def win_pinpad():
|
||||
|
||||
buttons["OK"].configure(state="disabled")
|
||||
|
||||
usernr.focus_set()
|
||||
|
||||
# Tkinter main loop
|
||||
|
||||
root.mainloop()
|
||||
|
||||
def win_userselection():
|
||||
|
||||
|
78
users.py
Normal file
78
users.py
Normal file
@ -0,0 +1,78 @@
|
||||
# Zeiterfassung
|
||||
|
||||
# User bezogene Funktionen
|
||||
|
||||
import os
|
||||
import datetime
|
||||
import time
|
||||
|
||||
from definitions import userfolder, scriptpath, usersettingsfilename, photofilename, status_in, status_out
|
||||
|
||||
# Benutzerklasse
|
||||
|
||||
class user:
|
||||
def __init__(self, name):
|
||||
self.userfolder = scriptpath + "/" + userfolder + "/" + name
|
||||
self.settingsfile = self.userfolder + "/" + usersettingsfilename
|
||||
self.photofile = self.userfolder + "/" + photofilename
|
||||
|
||||
def get_stamp_file(self):
|
||||
year = str(datetime.datetime.now().year)
|
||||
month = str(datetime.datetime.now().month)
|
||||
completepath = self.userfolder + "/" + year + "-" + month + ".txt"
|
||||
return completepath
|
||||
|
||||
def timestamp(self):
|
||||
filename = self.get_stamp_file()
|
||||
timestamp = int(time.time())
|
||||
|
||||
try:
|
||||
# Öffne die Datei im Anhang-Modus ('a')
|
||||
with open(filename, 'a') as file:
|
||||
# Schreibe den Timestamp in die Datei und füge einen Zeilenumbruch hinzu
|
||||
file.write(f"{timestamp}\n")
|
||||
file.close()
|
||||
except FileNotFoundError:
|
||||
# Fehlende Verzeichnisse anlegen
|
||||
folder_path = os.path.dirname(filename)
|
||||
os.makedirs(folder_path, exist_ok=True)
|
||||
self.timestamp()
|
||||
|
||||
def stamp_status(self):
|
||||
try:
|
||||
# Öffne die Datei im Lese-Modus ('r')
|
||||
with open(self.get_stamp_file(), 'r') as file:
|
||||
# Zähle die Zeilen
|
||||
lines = file.readlines()
|
||||
file.close()
|
||||
except FileNotFoundError:
|
||||
print(f"Die Datei {filename} wurde nicht gefunden.")
|
||||
if len(lines)== 0:
|
||||
print(f"Keine Einträge")
|
||||
elif len(lines) % 2 == 0:
|
||||
return (status_out)
|
||||
else:
|
||||
return (status_in)
|
||||
|
||||
def last_2_timestmaps(self):
|
||||
|
||||
with open(self.get_stamp_file(), 'r') as file:
|
||||
lines = file.readlines()
|
||||
file.close()
|
||||
|
||||
if len(lines) > 2:
|
||||
second_last_line = int(lines[-2])
|
||||
last_line = int(lines[-1])
|
||||
last_2_timestmaps = [second_last_line, last_line]
|
||||
return last_2_timestmaps
|
||||
|
||||
elif len(lines) == 1:
|
||||
return int(lines[0])
|
||||
else:
|
||||
return -1
|
||||
|
||||
# Benutzer auflisten
|
||||
def list_users(user):
|
||||
users = [d for d in os.listdir(userfolder) if os.path.isdir(os.path.join(userfolder, d))]
|
||||
return users
|
||||
|
0
users/test/2025-4.txt
Normal file
0
users/test/2025-4.txt
Normal file
Loading…
x
Reference in New Issue
Block a user