mirror of
https://github.com/FAUSheppy/homelab_gamevault
synced 2025-12-06 06:51:36 +01:00
wip: refactor & software class stub
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
*.zip
|
*.zip
|
||||||
|
*.swp
|
||||||
|
|||||||
50
client.py
50
client.py
@@ -1,6 +1,7 @@
|
|||||||
import tkinter
|
import tkinter
|
||||||
import customtkinter
|
import customtkinter
|
||||||
import PIL
|
import PIL
|
||||||
|
import data_backend
|
||||||
|
|
||||||
customtkinter.set_appearance_mode("dark")
|
customtkinter.set_appearance_mode("dark")
|
||||||
customtkinter.set_default_color_theme("blue")
|
customtkinter.set_default_color_theme("blue")
|
||||||
@@ -18,50 +19,65 @@ img = PIL.ImageTk.PhotoImage(img)
|
|||||||
|
|
||||||
buttons = []
|
buttons = []
|
||||||
|
|
||||||
def create_button():
|
def switch_to_game_details(software):
|
||||||
|
'''Switch to the details of the clicked tile'''
|
||||||
|
pass
|
||||||
|
|
||||||
button = customtkinter.CTkButton(app, image=img, width=200, height=300, command=lambda: button_click(button),
|
def create_main_window_tile(software):
|
||||||
border_width=0, corner_radius=0, border_spacing=0, text="Test Title LOLOLOL",
|
'''Create the main window tile'''
|
||||||
fg_color="transparent", compound="top", anchor="s")
|
|
||||||
|
button = customtkinter.CTkButton(app, image=img, width=200, height=300,
|
||||||
|
command=lambda: switch_to_game_details(game),
|
||||||
|
border_width=0, corner_radius=0, border_spacing=0,
|
||||||
|
text="Test Title LOLOLOL",
|
||||||
|
fg_color="transparent", compound="top", anchor="s")
|
||||||
return button
|
return button
|
||||||
|
|
||||||
def button_click():
|
|
||||||
print(button.cget("image"))
|
|
||||||
|
|
||||||
def update_button_positions(event=None):
|
def update_button_positions(event=None):
|
||||||
|
'''Sets the tile positions initially and on resize'''
|
||||||
|
|
||||||
global last_geometry
|
global last_geometry
|
||||||
|
|
||||||
|
# check vs old location #
|
||||||
new_geometry = app.winfo_geometry()
|
new_geometry = app.winfo_geometry()
|
||||||
if last_geometry[0] == new_geometry[0] and last_geometry[1] == new_geometry[1]:
|
if last_geometry[0] == new_geometry[0] and last_geometry[1] == new_geometry[1]:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
last_geometry = new_geometry
|
last_geometry = new_geometry
|
||||||
|
|
||||||
# Calculate the number of columns based on the current width of the window
|
# Calculate the number of columns based on the current width of the window #
|
||||||
num_columns = app.winfo_width() // 201 # Adjust 100 as needed for button width
|
num_columns = app.winfo_width() // 201 # Adjust 100 as needed for button width
|
||||||
|
|
||||||
# window became too slow #
|
# window became too small #
|
||||||
if num_columns == 0:
|
if num_columns == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# calculated and set positions
|
||||||
for i, button in enumerate(buttons):
|
for i, button in enumerate(buttons):
|
||||||
|
|
||||||
grid_info_current = button.grid_info()
|
grid_info_current = button.grid_info()
|
||||||
column_new = i % num_columns
|
column_new = i % num_columns
|
||||||
row_new = i // num_columns
|
row_new = i // num_columns
|
||||||
|
|
||||||
if grid_info_current.get("row") and grid_info_current["row"] == row_new and grid_info_current["column"] == column_new:
|
if(grid_info_current.get("row") and grid_info_current["row"] == row_new
|
||||||
|
and grid_info_current["column"] == column_new):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
button.grid(row=i // num_columns, column=i % num_columns, sticky="we")
|
button.grid(row=i // num_columns, column=i % num_columns, sticky="we")
|
||||||
|
|
||||||
|
|
||||||
for i in range(0,5):
|
if __init__ == "__main__":
|
||||||
button = create_button()
|
|
||||||
buttons.append(button)
|
|
||||||
|
|
||||||
app.bind("<Configure>", update_button_positions)
|
# define data backend #
|
||||||
update_button_positions()
|
db = data_backend.LocalFS(None, None, "./cache", remote_root_dir="example_software_root")
|
||||||
app.mainloop()
|
|
||||||
|
# create tiles from meta files #
|
||||||
|
for software in db.find_all_metadata():
|
||||||
|
create_main_window_tile(software)
|
||||||
|
|
||||||
|
# set update listener & update positions #
|
||||||
|
app.bind("<Configure>", update_button_positions)
|
||||||
|
update_button_positions()
|
||||||
|
|
||||||
|
# run app #
|
||||||
|
app.mainloop()
|
||||||
|
|||||||
13
software.py
Normal file
13
software.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
class Software:
|
||||||
|
|
||||||
|
def __init__(self, directory):
|
||||||
|
|
||||||
|
self.directory = directory
|
||||||
|
self.info_file =
|
||||||
|
|
||||||
|
self.genre =
|
||||||
|
self.title =
|
||||||
|
self.description =
|
||||||
|
self.dependencies =
|
||||||
|
self.link_only =
|
||||||
|
self.extra_files =
|
||||||
Reference in New Issue
Block a user