Erste UI Expoerimente
This commit is contained in:
parent
887fd14f72
commit
900e3cfd5a
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
__pycache__/ui.cpython-311.pyc
Normal file
BIN
__pycache__/ui.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -6,4 +6,5 @@ userfolder = "users"
|
||||
settingsfolder = "settings"
|
||||
usersettingsfilename = "settings.json"
|
||||
program_name = "Zeiterfassung"
|
||||
program_version = "Development"
|
||||
program_version = "Development"
|
||||
|
||||
|
@ -1,20 +1,28 @@
|
||||
# Zeiterfassung
|
||||
|
||||
# JSON Handling
|
||||
|
||||
# Imports
|
||||
|
||||
import json
|
||||
|
||||
from users import *
|
||||
from definitions import *
|
||||
|
||||
# Datenstrutur:
|
||||
# Datenstruktur:
|
||||
|
||||
# user: Benutzername
|
||||
# name: Vollständiger Name
|
||||
# password: gehashtes Passwort
|
||||
|
||||
# Montatsspezifische Informationen:
|
||||
# Gültigkeitsdatum, ab wann gülitg
|
||||
#
|
||||
# monday: Stunden
|
||||
# tuesday: Stunden
|
||||
# wednesday: Stunden
|
||||
# thursday: Stunden
|
||||
# friday: Stunden
|
||||
# saturday: Stunden
|
||||
# sunday: Stunden
|
||||
# pto: Tage pro Jahr
|
||||
|
||||
def load_settings(filename):
|
||||
|
||||
with open(filename) as json_file:
|
||||
|
22
test.json
Normal file
22
test.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"2024-04-01": {
|
||||
"0": "0",
|
||||
"1": "8",
|
||||
"2": "8",
|
||||
"3": "8",
|
||||
"4": "8",
|
||||
"5": "8",
|
||||
"6": "0",
|
||||
"vacation": "30"
|
||||
},
|
||||
"2024-04-07": {
|
||||
"0": "0",
|
||||
"1": "6",
|
||||
"2": "6",
|
||||
"3": "6",
|
||||
"4": "8",
|
||||
"5": "6",
|
||||
"6": "0",
|
||||
"vacation": "28"
|
||||
}
|
||||
}
|
29
testing ttk.py
Normal file
29
testing ttk.py
Normal file
@ -0,0 +1,29 @@
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
|
||||
# Funktion, die die Farben des Buttons ändert
|
||||
def aendere_farbe(button, bg_farbe, fg_farbe):
|
||||
# Ändern der Hintergrund- und Textfarbe des Buttons
|
||||
button.configure(bg=bg_farbe, fg=fg_farbe)
|
||||
|
||||
# Erstellen des Hauptfensters
|
||||
root = tk.Tk()
|
||||
root.title("Buttons mit unterschiedlichen Farben")
|
||||
|
||||
# Liste von Button-Beschriftungen und den gewünschten Farben
|
||||
button_info = [
|
||||
('Button 1', 'green', 'white'),
|
||||
('Button 2', 'blue', 'yellow'),
|
||||
('Button 3', 'red', 'black')
|
||||
]
|
||||
|
||||
# Erstellen der Buttons aus der Liste
|
||||
buttons = []
|
||||
for text, bg, fg in button_info:
|
||||
# Einen Button erstellen und die Farben ändern
|
||||
button = tk.Button(root, text=text, command=lambda b=button, bg=bg, fg=fg: aendere_farbe(b, bg, fg))
|
||||
button.pack(pady=10)
|
||||
buttons.append(button)
|
||||
|
||||
# Hauptloop starten
|
||||
root.mainloop()
|
@ -15,6 +15,7 @@ def append_timestamp(filename):
|
||||
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)
|
||||
@ -28,7 +29,9 @@ def len_timestamps(filename):
|
||||
with open(filename, 'r') as file:
|
||||
# Zähle die Zeilen
|
||||
lines = file.readlines()
|
||||
return len(lines)
|
||||
file.close()
|
||||
print(len(lines))
|
||||
return len(lines)
|
||||
except FileNotFoundError:
|
||||
print(f"Die Datei {filename} wurde nicht gefunden.")
|
||||
return 0
|
||||
@ -50,23 +53,33 @@ def overview(filename):
|
||||
with open(filename, 'r') as file:
|
||||
lines = file.readlines()
|
||||
|
||||
in_times = []
|
||||
out_times = []
|
||||
timelist = [[] for i in range(3)]
|
||||
|
||||
for i in range(0, len(lines)):
|
||||
if (i + 1) % 2 == 0:
|
||||
out_times.append(lines[i])
|
||||
timelist[1].append(lines[i])
|
||||
else:
|
||||
in_times.append(lines[i])
|
||||
if len(in_times) > len(out_times):
|
||||
out_times.append("")
|
||||
for i in range(0, len(in_times)):
|
||||
print(convert_timestamp(in_times[i], "%d.%m.%Y %H:%M") + " - " + convert_timestamp(out_times[i], "%H:%M"))
|
||||
timelist[0].append(lines[i])
|
||||
if len(timelist[0]) > len(timelist[1]):
|
||||
timelist[1].append("")
|
||||
|
||||
for i in range(0, len(timelist[0])):
|
||||
timelist[2].append(int(timelist[1][i])-int(timelist[0][i]))
|
||||
|
||||
for i in range(0, len(timelist[0])):
|
||||
print(convert_timestamp(timelist[0][i], "%d.%m.%Y %H:%M") + " - " + convert_timestamp(timelist[1][i], "%d.%m.%Y %H:%M") + " Dauer: " + convert_duration(timelist[2][i]))
|
||||
|
||||
# Timestamp konvertieren
|
||||
def convert_timestamp(timestamp, format):
|
||||
try:
|
||||
return str(datetime.datetime.fromtimestamp(int(timestamp)).strftime(format))
|
||||
except:
|
||||
return ("...")
|
||||
return ("...")
|
||||
|
||||
#Zeitdauerdarstellung berechnen
|
||||
def convert_duration(duration):
|
||||
hours = int(duration / 3600)
|
||||
minutes = int((duration - hours * 3600) / 60)
|
||||
seconds = int(duration - hours * 3600 - minutes * 60)
|
||||
|
||||
return(f"{hours:02d}" + ":" + f"{minutes:02d}" + ":" + f"{seconds:02d}")
|
46
ui.py
Normal file
46
ui.py
Normal file
@ -0,0 +1,46 @@
|
||||
# Zeiterfassung
|
||||
# UI
|
||||
from wx.lib.agw.aui import aero_up_single
|
||||
|
||||
from definitions import *
|
||||
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from tkinter import messagebox
|
||||
|
||||
from timestamping import append_timestamp, len_timestamps
|
||||
from users import determine_filename
|
||||
|
||||
|
||||
def ui_stempeln(button, label):
|
||||
append_timestamp(determine_filename(label))
|
||||
global buttons
|
||||
if len_timestamps(determine_filename(label)) % 2 == 0:
|
||||
buttons[button].configure(relief="raised", bg="red")
|
||||
else:
|
||||
buttons[button].configure(relief="sunken", bg="green")
|
||||
|
||||
def stempeln(userlist):
|
||||
stempeln = tk.Tk()
|
||||
stempeln.title(program_name + " " + program_version)
|
||||
stempeln.geometry("600x400")
|
||||
stempeln.minsize(width=200, height=200)
|
||||
|
||||
global buttons
|
||||
buttons = [ ]
|
||||
button_index = 0
|
||||
windowSize = stempeln.winfo_height()
|
||||
|
||||
|
||||
for i in userlist:
|
||||
buttonheight = int(windowSize / len(userlist) - 10)
|
||||
button = tk.Button(stempeln, text=i, height=buttonheight, command=lambda b=button_index, label=i: ui_stempeln(b, label))
|
||||
if len_timestamps(determine_filename(i)) % 2 == 0:
|
||||
button.configure(relief="raised", bg ="red")
|
||||
else:
|
||||
button.configure(relief="sunken", bg="green")
|
||||
button.pack(fill="x", pady=5)
|
||||
buttons.append(button)
|
||||
button_index+=1
|
||||
|
||||
stempeln.mainloop()
|
11
users.py
11
users.py
@ -2,7 +2,6 @@
|
||||
# Benutzerfunktionen
|
||||
|
||||
import os
|
||||
import time
|
||||
import datetime
|
||||
|
||||
from definitions import *
|
||||
@ -22,7 +21,13 @@ def determine_filename(user, type="stamping"):
|
||||
completepath = scriptpath() + "/" + userfolder +"/" + user + "/" + usersettingsfilename
|
||||
return completepath
|
||||
|
||||
# Benutzerliste anzeigen
|
||||
def printUserList():
|
||||
userlist = list_users(scriptpath() + "/" + userfolder)
|
||||
for i in range(0, len(userlist)):
|
||||
print(str(i + 1) + ": " + str(userlist[i]))
|
||||
return(userlist)
|
||||
|
||||
# Installationsverzeichnis bestimmen
|
||||
def scriptpath():
|
||||
|
||||
return os.path.dirname(os.path.abspath(__file__))
|
||||
return os.path.dirname(os.path.abspath(__file__))
|
||||
|
@ -7,3 +7,68 @@
|
||||
1743967346
|
||||
1744024713
|
||||
1744024974
|
||||
1744107474
|
||||
1744194019
|
||||
1744194047
|
||||
1744194048
|
||||
1744194049
|
||||
1744194602
|
||||
1744194612
|
||||
1744194613
|
||||
1744194613
|
||||
1744194614
|
||||
1744194709
|
||||
1744196085
|
||||
1744196089
|
||||
1744196089
|
||||
1744196120
|
||||
1744196189
|
||||
1744196243
|
||||
1744196307
|
||||
1744196315
|
||||
1744196324
|
||||
1744196333
|
||||
1744196334
|
||||
1744196335
|
||||
1744196337
|
||||
1744196338
|
||||
1744196339
|
||||
1744196340
|
||||
1744196342
|
||||
1744196343
|
||||
1744196344
|
||||
1744196345
|
||||
1744196346
|
||||
1744196500
|
||||
1744196505
|
||||
1744196506
|
||||
1744196507
|
||||
1744196663
|
||||
1744196665
|
||||
1744196667
|
||||
1744196667
|
||||
1744196719
|
||||
1744196721
|
||||
1744196991
|
||||
1744197071
|
||||
1744197205
|
||||
1744197211
|
||||
1744197213
|
||||
1744197215
|
||||
1744197217
|
||||
1744197218
|
||||
1744197219
|
||||
1744197253
|
||||
1744197300
|
||||
1744197301
|
||||
1744197302
|
||||
1744197303
|
||||
1744197765
|
||||
1744197766
|
||||
1744197769
|
||||
1744197868
|
||||
1744197871
|
||||
1744198070
|
||||
1744198071
|
||||
1744198392
|
||||
1744198393
|
||||
|
@ -1,5 +1,25 @@
|
||||
{
|
||||
"username": "testuser",
|
||||
"name": "Der neue Tester",
|
||||
"password": "123456789"
|
||||
"password": "123456789",
|
||||
"2024-04-01": {
|
||||
"0": "0",
|
||||
"1": "8",
|
||||
"2": "8",
|
||||
"3": "8",
|
||||
"4": "8",
|
||||
"5": "8",
|
||||
"6": "0",
|
||||
"vacation": "30"
|
||||
},
|
||||
"2024-04-07": {
|
||||
"0": "0",
|
||||
"1": "6",
|
||||
"2": "6",
|
||||
"3": "6",
|
||||
"4": "8",
|
||||
"5": "6",
|
||||
"6": "0",
|
||||
"vacation": "28"
|
||||
}
|
||||
}
|
@ -6,3 +6,15 @@
|
||||
1744018696
|
||||
1744100316
|
||||
1744100330
|
||||
1744194603
|
||||
1744196086
|
||||
1744196347
|
||||
1744196348
|
||||
1744196349
|
||||
1744196350
|
||||
1744196350
|
||||
1744196351
|
||||
1744197304
|
||||
1744197306
|
||||
1744197767
|
||||
1744197768
|
||||
|
@ -3,31 +3,28 @@
|
||||
# Zeiterfassung
|
||||
|
||||
# Bibliotheksimports
|
||||
import time
|
||||
import datetime
|
||||
import os
|
||||
from timestamping import *
|
||||
from users import *
|
||||
from jsonhandler import *
|
||||
from definitions import *
|
||||
from ui import *
|
||||
|
||||
# Funktionen
|
||||
|
||||
def printUserList():
|
||||
userlist = list_users(scriptpath() + "/" + userfolder)
|
||||
for i in range(0, len(userlist)):
|
||||
print(str(i + 1) + ": " + str(userlist[i]))
|
||||
return(userlist)
|
||||
|
||||
# Hauptfunktion
|
||||
def main():
|
||||
|
||||
userList = printUserList()
|
||||
stempeln(userList)
|
||||
exit()
|
||||
|
||||
# Konsole
|
||||
while True:
|
||||
|
||||
print(program_name + " " + str(program_version))
|
||||
print("Welche Funktion soll ausgeführt werden?")
|
||||
print("1: Stempeln")
|
||||
print("2: Stempelübersicht anzeigen")
|
||||
print("3: Einstellungen ändern")
|
||||
print("0: Beenden")
|
||||
question = int(input("Geben Sie Ihre Antwort ein: "))
|
||||
|
||||
@ -42,23 +39,6 @@ def main():
|
||||
print("Zustand: " + stempel_zustand(determine_filename(userlist[int(which_user) -1])))
|
||||
overview(determine_filename(userlist[int(which_user) - 1]))
|
||||
|
||||
elif question == 3:
|
||||
userlist = printUserList()
|
||||
which_user = input("Für welchen Benutzer sollen die Einstellungen geändert werden? ")
|
||||
selected_user = userlist[int(which_user) - 1]
|
||||
print("Benutzereinstellungen für Benutzer " + str(selected_user) + ":")
|
||||
settings = load_settings(determine_filename(selected_user, "settings"))
|
||||
for x in settings:
|
||||
print(x + ": " + settings[x])
|
||||
setting_to_change = input("Welche Einstellung soll geändert werden? ")
|
||||
if setting_to_change in settings:
|
||||
new_value = input("Wie ist der neue Wert? ")
|
||||
settings[setting_to_change] = new_value
|
||||
for x in settings:
|
||||
print(x + ": " + settings[x])
|
||||
print("Speicher Einstellungen")
|
||||
write_settings(determine_filename(selected_user, type="settings"), settings)
|
||||
|
||||
elif question == 0:
|
||||
exit()
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user