From 557ee221d59ec831f4686c80016182ef92650508 Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 26 Jan 2023 11:10:49 +0100 Subject: [PATCH] Cards size depending on OS --- classes/frames/device.py | 12 +++++++----- classes/frames/save.py | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/classes/frames/device.py b/classes/frames/device.py index 4821777..478197f 100644 --- a/classes/frames/device.py +++ b/classes/frames/device.py @@ -9,7 +9,7 @@ import requests from classes.custom.themed_frame import ThemedFrame from modules.logger import logger -from modules.utils import configGet, configSet +from modules.utils import configGet, configSet, osname class FrameDevice(ThemedFrame): @@ -18,17 +18,19 @@ class FrameDevice(ThemedFrame): super().__init__(master, style="Card.TFrame", **kwargs) + self.widget_width = 47 if osname == "nt" else 42 + self.grid_columnconfigure(0, weight=1) self.grid_columnconfigure(1, weight=3) self.grid_columnconfigure(2, weight=3) self.name = device_dict["name"] - self.title = ttk.Label(self, text=self.name, font=("SunValleyBodyStrongFont", 12, "bold"), justify=LEFT, width=46) + self.title = ttk.Label(self, text=self.name, font=("SunValleyBodyStrongFont", 12, "bold"), justify=LEFT, width=self.widget_width) self.title.grid(column=0, row=0, padx=9, pady=9, sticky=W) last_upload = "N/A" if device_dict["last_save"] == 0 else datetime.utcfromtimestamp(device_dict["last_save"]).strftime("%d.%m.%Y %H:%M") - self.description = ttk.Label(self, text=f'OS: {device_dict["os"]}\nClient: {device_dict["client"]}\nLast upload: {last_upload}', width=46) + self.description = ttk.Label(self, text=f'OS: {device_dict["os"]}\nClient: {device_dict["client"]}\nLast upload: {last_upload}', width=self.widget_width) self.description.grid(column=0, row=1, padx=9, pady=9, sticky=W) self.buttons = ThemedFrame(self) @@ -94,7 +96,7 @@ class FrameDevice(ThemedFrame): if isinstance(widget, ttk.Entry): widget.destroy() - device_title = ttk.Label(self, text=self.name, font=("SunValleyBodyStrongFont", 12, "bold"), justify=LEFT, width=46) + device_title = ttk.Label(self, text=self.name, font=("SunValleyBodyStrongFont", 12, "bold"), justify=LEFT, width=self.widget_width) device_title.grid(column=0, row=0, padx=9, pady=9, sticky=W) button_device_rename_action = partial(self.rename) @@ -117,7 +119,7 @@ class FrameDevice(ThemedFrame): if isinstance(widget, ttk.Entry): widget.destroy() - device_title = ttk.Label(self, text=self.name, font=("SunValleyBodyStrongFont", 12, "bold"), justify=LEFT, width=46) + device_title = ttk.Label(self, text=self.name, font=("SunValleyBodyStrongFont", 12, "bold"), justify=LEFT, width=self.widget_width) device_title.grid(column=0, row=0, padx=9, pady=9, sticky=W) button_device_rename_action = partial(self.rename) diff --git a/classes/frames/save.py b/classes/frames/save.py index 307d595..3cf9a79 100644 --- a/classes/frames/save.py +++ b/classes/frames/save.py @@ -2,6 +2,7 @@ from datetime import datetime, timezone from tkinter import LEFT, NSEW, Misc, S, W, ttk from classes.custom.themed_frame import ThemedFrame +from modules.utils import osname class FrameSave(ThemedFrame): @@ -10,14 +11,16 @@ class FrameSave(ThemedFrame): super().__init__(master, style="Card.TFrame", **kwargs) + self.widget_width = 47 if osname == "nt" else 42 + self.grid_columnconfigure(0, weight=1) self.grid_columnconfigure(1, weight=3) self.grid_columnconfigure(2, weight=3) - self.title = ttk.Label(self, text=save_dict["data"]["farmer"], font=("SunValleyBodyStrongFont", 12, "bold"), justify=LEFT, width=46) + self.title = ttk.Label(self, text=save_dict["data"]["farmer"], font=("SunValleyBodyStrongFont", 12, "bold"), justify=LEFT, width=self.widget_width) self.title.grid(column=0, row=0, padx=9, pady=9, sticky=W) - self.description = ttk.Label(self, text=f'Money: {save_dict["data"]["money"]}\nGame version: {save_dict["data"]["game_version"]}\nID: {save_dict["id"]}', width=46) + self.description = ttk.Label(self, text=f'Money: {save_dict["data"]["money"]}\nGame version: {save_dict["data"]["game_version"]}\nID: {save_dict["id"]}', width=self.widget_width) self.description.grid(column=0, row=1, padx=9, pady=9, sticky=W) self.buttons = ThemedFrame(self) @@ -25,7 +28,7 @@ class FrameSave(ThemedFrame): self.buttons.grid_columnconfigure(0, weight=1) upload_date = datetime.utcfromtimestamp(save_dict["date"]).replace(tzinfo=timezone.utc).astimezone(tz=None) - self.last_upload = ttk.Label(self.buttons, text=f'{upload_date.strftime("%A, %d %b %Y")}\nUploaded at {upload_date.strftime("%H:%M")} by {save_dict["device"]}', font=("SunValleyBodyFont", 8), justify=LEFT, width=46) + self.last_upload = ttk.Label(self.buttons, text=f'{upload_date.strftime("%A, %d %b %Y")}\nUploaded at {upload_date.strftime("%H:%M")} by {save_dict["device"]}', font=("SunValleyBodyFont", 8), justify=LEFT, width=self.widget_width) self.last_upload.grid(column=0, row=0, sticky=W+S) # self.button_device_rename_action = partial(self.rename) @@ -34,4 +37,10 @@ class FrameSave(ThemedFrame): #self.button_device_delete_action = partial(self.delete) self.button_device_delete = ttk.Button(self.buttons, text="Synchronize", style="Accent.TButton", width=11) #, command=self.button_device_delete_action) - self.button_device_delete.grid(column=1, row=0, sticky=W) \ No newline at end of file + self.button_device_delete.grid(column=1, row=0, sticky=W) + + def convert_date(self, year: int, month: int, day: int) -> str: + pass + + def convert_playtime(self, seconds: int) -> str: + pass \ No newline at end of file