78 lines
2.0 KiB
Python
78 lines
2.0 KiB
Python
from gi.overrides.keysyms import value
|
|
from nicegui import ui, events
|
|
from users import *
|
|
from definitions import *
|
|
|
|
@ui.page('/login')
|
|
def page_login():
|
|
ui.label('Loginseite')
|
|
|
|
@ui.page('/stamping')
|
|
def page_stamping():
|
|
ui.label('Stempelsteite')
|
|
|
|
@ui.page('/touchscreen')
|
|
def page_touchscreen():
|
|
|
|
def button_click(name):
|
|
nonlocal buttons
|
|
current_user = user(name)
|
|
current_user.timestamp()
|
|
if current_user.stamp_status() == status_in:
|
|
buttons[name].props('color=green')
|
|
ui.notify(status_in)
|
|
else:
|
|
buttons[name].props('color=red')
|
|
ui.notify(status_out)
|
|
|
|
ui.markdown(f"##{app_title} {app_version}")
|
|
|
|
userlist = list_users()
|
|
number_of_users = len(userlist)
|
|
buttons = { }
|
|
|
|
if number_of_users > 5:
|
|
number_of_columns = 5
|
|
else:
|
|
number_of_columns = number_of_users
|
|
|
|
|
|
with ui.grid(columns=number_of_columns):
|
|
for name in userlist:
|
|
current_user = user(name)
|
|
current_button = ui.button(on_click=lambda name=name: button_click(name))
|
|
with current_button:
|
|
try:
|
|
with open(current_user.photofile, 'r') as file:
|
|
pass
|
|
file.close()
|
|
ui.image(current_user.photofile)
|
|
except:
|
|
pass
|
|
ui.label(current_user.fullname)
|
|
if current_user.stamp_status() == status_in:
|
|
current_button.props('color=green')
|
|
else:
|
|
current_button.props('color=red')
|
|
buttons[name] = current_button
|
|
|
|
|
|
@ui.page('/userlist')
|
|
def page_userlist():
|
|
|
|
def click_button(button):
|
|
ui.notify(button)
|
|
|
|
ui.markdown(f"#{app_title} {app_version}")
|
|
|
|
userlist = list_users()
|
|
buttons = { }
|
|
|
|
for name in userlist:
|
|
button = ui.button(text=name, on_click=lambda name=name:click_button(name) )
|
|
buttons[name] = button
|
|
|
|
ui.run(port=8090)
|
|
|
|
|