2023-01-25 17:23:18 +02:00
|
|
|
from tkinter import NSEW, ttk
|
|
|
|
|
2023-01-22 18:53:55 +02:00
|
|
|
from ttkthemes import ThemedTk
|
|
|
|
|
2023-01-23 01:13:30 +02:00
|
|
|
from classes.custom.scrollable_frame import ScrollableFrame
|
2023-01-22 18:53:55 +02:00
|
|
|
from classes.custom.themed_frame import ThemedFrame
|
2023-01-25 17:23:18 +02:00
|
|
|
from classes.frames.device import FrameDevice
|
2023-01-22 18:53:55 +02:00
|
|
|
|
|
|
|
|
2023-01-23 01:13:30 +02:00
|
|
|
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:
|
|
|
|
|
2023-01-25 15:01:13 +02:00
|
|
|
device_frame = FrameDevice(self, device_dict=device)
|
2023-01-23 01:13:30 +02:00
|
|
|
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):
|
2023-01-22 18:53:55 +02:00
|
|
|
|
|
|
|
def __init__(self, master: ThemedTk, **kwargs) -> None:
|
|
|
|
|
|
|
|
super().__init__(master, **kwargs)
|
|
|
|
|
|
|
|
master.title("Devices - Stardew Sync")
|
|
|
|
|
2023-01-23 01:13:30 +02:00
|
|
|
self.grid_columnconfigure(0, weight=1)
|
|
|
|
self.grid_rowconfigure(0, weight=2)
|
2023-01-22 18:53:55 +02:00
|
|
|
|
2023-01-23 01:13:30 +02:00
|
|
|
master.columnconfigure(1, weight=1)
|
2023-01-22 18:53:55 +02:00
|
|
|
|
2023-01-23 01:13:30 +02:00
|
|
|
self.label = ttk.Label(self, text="No devices found")
|
|
|
|
self.label.grid(column=0, row=0, padx=9, pady=9)
|