SyncTk/classes/frames/devices.py
2023-01-25 16:23:18 +01:00

53 lines
1.4 KiB
Python

from tkinter import NSEW, ttk
from ttkthemes import ThemedTk
from classes.custom.scrollable_frame import ScrollableFrame
from classes.custom.themed_frame import ThemedFrame
from classes.frames.device import FrameDevice
class FrameDevices(ScrollableFrame):
def __init__(self, master: ThemedTk, devices: list, **kwargs) -> None:
super().__init__(master, **kwargs)
master.title("Devices - Stardew Sync")
self.devices = devices
master.columnconfigure(1, weight=1)
self.render_devices()
def render_devices(self):
i = 0
for device in self.devices:
device_frame = FrameDevice(self, device_dict=device)
device_frame.grid(column=0, row=i, pady=9, padx=9, sticky=NSEW)
i += 1
if i+1 != len(self.devices):
divider = ttk.Separator(self, orient="horizontal")
divider.grid(column=0, row=i+1, pady=9)
i += 1
class FrameDevicesEmpty(ThemedFrame):
def __init__(self, master: ThemedTk, **kwargs) -> None:
super().__init__(master, **kwargs)
master.title("Devices - Stardew Sync")
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=2)
master.columnconfigure(1, weight=1)
self.label = ttk.Label(self, text="No devices found")
self.label.grid(column=0, row=0, padx=9, pady=9)