From 1a6e49c34bc9c77dbb8d31be542bafef0504f071 Mon Sep 17 00:00:00 2001 From: Alexander Malzkuhn Date: Wed, 4 Jun 2025 12:36:09 +0200 Subject: [PATCH] =?UTF-8?q?Touchscreen=20Styling=20ver=C3=A4ndert=20SVG=20?= =?UTF-8?q?f=C3=BCr=20fehlendes=20Foto=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/definitions.py | 38 +++++++++++- lib/touchscreen.py | 121 +++++++++++++++++++++++++++++---------- no-photo-svgrepo-com.svg | 33 +++++++++++ 3 files changed, 162 insertions(+), 30 deletions(-) create mode 100644 no-photo-svgrepo-com.svg diff --git a/lib/definitions.py b/lib/definitions.py index caf3215..1b9de6d 100644 --- a/lib/definitions.py +++ b/lib/definitions.py @@ -90,4 +90,40 @@ absence_entries = {"U": { "name": "Urlaub", h1 = "text-5xl font-bold" h2 = "text-4xl font-medium" h3 = "text-3xl font-light" -h4 = "text-2xl" \ No newline at end of file +h4 = "text-2xl" + +# SVGs: + +no_photo_svg = f''' + + + + + + + + + + + + + + + + + +''' \ No newline at end of file diff --git a/lib/touchscreen.py b/lib/touchscreen.py index c3d626b..47c713d 100644 --- a/lib/touchscreen.py +++ b/lib/touchscreen.py @@ -36,44 +36,107 @@ def page_touchscreen(): number_of_users = len(userlist) buttons = { } + number_of_columns = 5 + + def set_columns(width): + nonlocal number_of_columns + print(width) + if width > 1400: + number_of_columns = 6 + elif width > 1200: + number_of_columns = 5 + elif width > 900: + number_of_columns = 4 + elif width > 750: + number_of_columns = 3 + else: + number_of_columns = 2 + user_buttons.refresh() + + ui.on('resize', lambda e: set_columns(e.args['width'])) + @ui.refreshable def user_buttons(): - if number_of_users > 5: - number_of_columns = 5 - else: - number_of_columns = number_of_users + + # Fenstergröße bestimmen und dann Spalten anpassen + ui.add_head_html(''' + + ''') with ui.grid(columns=number_of_columns).classes('w-full center'): + for name in userlist: current_user = user(name) current_button = ui.button(on_click=lambda name=name: button_click(name)).classes(f'w-md h-full min-h-[{admin_settings["button_height"]}px]') with current_button: - if admin_settings["photos_on_touchscreen"]: - try: - with open(current_user.photofile, 'r') as file: - pass - ui.image(current_user.photofile).classes(f'max-h-[{admin_settings["picture_height"]}px]').props('fit=scale-down') - except: - pass - column_classes = "w-full items-center" - if admin_settings["times_on_touchscreen"] or admin_settings["photos_on_touchscreen"]: - column_classes += " self-end" - with ui.column().classes(column_classes): - if admin_settings["times_on_touchscreen"]: - todays_timestamps = current_user.get_day_timestamps() - # Wenn wir Einträge haben - if len(todays_timestamps) > 0 and admin_settings["times_on_touchscreen"]: - table_string = "" - for i in range(0, len(todays_timestamps), 2): - try: - table_string += f"{datetime.datetime.fromtimestamp(todays_timestamps[i]).strftime('%H:%M')} - {datetime.datetime.fromtimestamp(todays_timestamps[i+1]).strftime('%H:%M')}" - except IndexError: - table_string += f"{datetime.datetime.fromtimestamp(todays_timestamps[i]).strftime('%H:%M')} -" - if i < len(todays_timestamps) - 2: - table_string += ", " - ui.label(table_string) - ui.label(current_user.fullname).classes('text-center') + with ui.grid(columns='1fr 1fr').classes('w-full h-full py-5 items-start'): + + if admin_settings["photos_on_touchscreen"]: + image_size = int(admin_settings["picture_height"]) + try: + with open(current_user.photofile, 'r') as file: + pass + ui.image(current_user.photofile).classes(f'max-h-[{image_size}px]').props('fit=scale-down') + except: + no_photo_svg = f''' + + + + + + + + + + + + + + + + + + ''' + ui.html(no_photo_svg) + with ui.column().classes('' if admin_settings["photos_on_touchscreen"] else 'col-span-2'): + ui.label(current_user.fullname).classes('text-left text-xl text.bold') + if admin_settings["times_on_touchscreen"]: + todays_timestamps = current_user.get_day_timestamps() + # Wenn wir Einträge haben + if len(todays_timestamps) > 0 and admin_settings["times_on_touchscreen"]: + table_string = "" + for i in range(0, len(todays_timestamps), 2): + try: + table_string += f"{datetime.datetime.fromtimestamp(todays_timestamps[i]).strftime('%H:%M')} - {datetime.datetime.fromtimestamp(todays_timestamps[i+1]).strftime('%H:%M')}" + except IndexError: + table_string += f"{datetime.datetime.fromtimestamp(todays_timestamps[i]).strftime('%H:%M')} -" + if i < len(todays_timestamps) - 2: + table_string += "\n" + ui.label(table_string).style('white-space: pre-wrap').classes('text-left') if current_user.stamp_status() == status_in: current_button.props('color=green') else: diff --git a/no-photo-svgrepo-com.svg b/no-photo-svgrepo-com.svg new file mode 100644 index 0000000..6c2d79d --- /dev/null +++ b/no-photo-svgrepo-com.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file