Working on new welcome screen
This commit is contained in:
parent
a49f629bfc
commit
67270252d2
@ -13,7 +13,7 @@ from classes.frames.saves import FrameSaves
|
|||||||
from classes.frames.settings import FrameSettings
|
from classes.frames.settings import FrameSettings
|
||||||
from classes.toplevel.welcome import ToplevelWelcome
|
from classes.toplevel.welcome import ToplevelWelcome
|
||||||
from modules.theme_titlebar import theme_title_bar
|
from modules.theme_titlebar import theme_title_bar
|
||||||
from modules.utils import configGet, get_string_mode, set_icon, use_dark_mode
|
from modules.utils import configGet, get_string_mode, resize_window, set_icon, use_dark_mode
|
||||||
|
|
||||||
|
|
||||||
class App(ThemedTk):
|
class App(ThemedTk):
|
||||||
@ -23,18 +23,10 @@ class App(ThemedTk):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.__version__ = "0.1.0"
|
self.__version__ = "0.1.0"
|
||||||
|
|
||||||
self.window_width = 600
|
resize_window(self, 610, 400)
|
||||||
self.window_height = 400
|
|
||||||
|
|
||||||
self.screen_width = self.winfo_screenwidth()
|
|
||||||
self.screen_height = self.winfo_screenheight()
|
|
||||||
|
|
||||||
self.center_x = int(self.screen_width/2 - self.window_width / 2)
|
|
||||||
self.center_y = int(self.screen_height/2 - self.window_height / 2)
|
|
||||||
|
|
||||||
self.title("Stardew Sync")
|
self.title("Stardew Sync")
|
||||||
self.geometry(f'{self.window_width}x{self.window_height}+{self.center_x}+{self.center_y}')
|
|
||||||
|
|
||||||
self.resizable(False, True)
|
self.resizable(False, True)
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class FrameDevices(ScrollableFrame):
|
|||||||
button_device_delete.grid(column=1, row=0, sticky=W)
|
button_device_delete.grid(column=1, row=0, sticky=W)
|
||||||
|
|
||||||
if device["name"] == configGet("name"):
|
if device["name"] == configGet("name"):
|
||||||
button_device_rename.state(["disabled"])
|
# button_device_rename.state(["disabled"])
|
||||||
button_device_delete.state(["disabled"])
|
button_device_delete.state(["disabled"])
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -78,8 +78,11 @@ class FrameErrorUnconfigured(ThemedFrame):
|
|||||||
|
|
||||||
master.columnconfigure(1, weight=1)
|
master.columnconfigure(1, weight=1)
|
||||||
|
|
||||||
self.label = ttk.Label(self, text="Client uncofigured")
|
self.label = ttk.Label(self, text="Client not configured")
|
||||||
self.label.grid(column=0, row=0, padx=9, pady=9, sticky=S)
|
self.label.grid(column=0, row=0, padx=9, pady=9, sticky=S)
|
||||||
|
|
||||||
self.button_settings = ttk.Button(self, text="Settings", style="Accent.TButton", width=10, command=master.frame_settings)
|
self.frame_buttons = ThemedFrame(self)
|
||||||
self.button_settings.grid(column=0, row=1, sticky=N)
|
self.frame_buttons.grid(column=0, row=1, sticky=N)
|
||||||
|
|
||||||
|
self.button_settings = ttk.Button(self.frame_buttons, text="Settings", style="Accent.TButton", width=10, command=master.frame_settings)
|
||||||
|
self.button_settings.grid(column=0, row=0, padx=9, pady=9)
|
@ -1,14 +1,15 @@
|
|||||||
from os import path
|
from os import path
|
||||||
from tkinter import CENTER, END, E, Image, IntVar, N, S, PhotoImage, Toplevel, W, messagebox, ttk
|
from tkinter import CENTER, END, E, LEFT, NSEW, Image, IntVar, N, S, PhotoImage, Toplevel, W, messagebox, ttk
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import sv_ttk
|
import sv_ttk
|
||||||
from classes.custom.image_label import ImageLabel
|
from classes.custom.image_label import ImageLabel
|
||||||
|
from classes.custom.themed_frame import ThemedFrame
|
||||||
|
|
||||||
from classes.custom.themed_toplevel import ThemedToplevel
|
from classes.custom.themed_toplevel import ThemedToplevel
|
||||||
from modules.logger import logger
|
from modules.logger import logger
|
||||||
from modules.theme_titlebar import theme_title_bar
|
from modules.theme_titlebar import theme_title_bar
|
||||||
from modules.utils import configGet, configSet, set_icon, use_dark_mode
|
from modules.utils import configGet, configSet, resize_window, set_icon, use_dark_mode
|
||||||
|
|
||||||
|
|
||||||
class ToplevelWelcome(ThemedToplevel):
|
class ToplevelWelcome(ThemedToplevel):
|
||||||
@ -17,19 +18,13 @@ class ToplevelWelcome(ThemedToplevel):
|
|||||||
|
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.window_width = 380
|
self.protocol("WM_DELETE_WINDOW", self.__exit)
|
||||||
self.window_height = 350
|
|
||||||
|
|
||||||
self.screen_width = self.winfo_screenwidth()
|
resize_window(self, 380, 350)
|
||||||
self.screen_height = self.winfo_screenheight()
|
|
||||||
|
|
||||||
self.center_x = int(self.screen_width/2 - self.window_width / 2)
|
|
||||||
self.center_y = int(self.screen_height/2 - self.window_height / 2)
|
|
||||||
|
|
||||||
self.title("Welcome to Stardew Sync")
|
self.title("Welcome to Stardew Sync")
|
||||||
self.geometry(f'{self.window_width}x{self.window_height}+{self.center_x}+{self.center_y}')
|
|
||||||
|
|
||||||
self.resizable(False, True)
|
self.resizable(False, False)
|
||||||
|
|
||||||
sv_ttk.init_theme(self)
|
sv_ttk.init_theme(self)
|
||||||
|
|
||||||
@ -43,19 +38,61 @@ class ToplevelWelcome(ThemedToplevel):
|
|||||||
|
|
||||||
self.grid_columnconfigure(0, weight=1)
|
self.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
self.welcome_pic = ImageLabel(self)
|
self.window_frame = ThemedFrame(self)
|
||||||
|
self.window_frame.grid(column=0, row=0, sticky=NSEW)
|
||||||
|
|
||||||
|
self.window_frame["borderwidth"] = 1
|
||||||
|
self.window_frame["relief"] = "solid"
|
||||||
|
|
||||||
|
self.window_frame.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
|
self.welcome_pic = ImageLabel(self.window_frame)
|
||||||
self.welcome_pic.grid(column=0, row=0, pady=20)
|
self.welcome_pic.grid(column=0, row=0, pady=20)
|
||||||
self.welcome_pic.load(path.join("assets", "welcome.gif"))
|
self.welcome_pic.load(path.join("assets", "welcome.gif"))
|
||||||
|
|
||||||
self.welcome_text = ttk.Label(self, text="Welcome to Stardew Sync", font=("SunValleyBodyFont", 14))
|
self.welcome_text = ttk.Label(self.window_frame, text="Welcome to Stardew Sync", font=("SunValleyBodyFont", 14))
|
||||||
self.welcome_text.grid(column=0, row=1, pady=10)
|
self.welcome_text.grid(column=0, row=1, pady=10)
|
||||||
|
|
||||||
self.welcome_subtext = ttk.Label(self, text="This small open-source application will help you\nto synchronize your Stardew Valley save files\nbetween all your devices", justify=CENTER)
|
self.welcome_subtext = ttk.Label(self.window_frame, text="This small open-source application will help you\nto synchronize your Stardew Valley save files\nbetween all your devices", justify=CENTER)
|
||||||
self.welcome_subtext.grid(column=0, row=2)
|
self.welcome_subtext.grid(column=0, row=2)
|
||||||
|
|
||||||
self.welcome_button = ttk.Button(self, text="Begin", style="Accent.TButton", width=10, command=self.acknowledged)
|
self.welcome_button = ttk.Button(self.window_frame, text="Begin", style="Accent.TButton", width=10, command=self.stage_address)
|
||||||
self.welcome_button.grid(column=0, row=3, pady=20)
|
self.welcome_button.grid(column=0, row=3, pady=20)
|
||||||
|
|
||||||
|
def stage_address(self):
|
||||||
|
|
||||||
|
for widget in self.window_frame.winfo_children():
|
||||||
|
widget.destroy()
|
||||||
|
|
||||||
|
self.window_frame.grid_rowconfigure(0, weight=2)
|
||||||
|
self.window_frame.grid_rowconfigure(1, weight=2)
|
||||||
|
#self.window_frame.grid_rowconfigure(2, weight=3)
|
||||||
|
|
||||||
|
self.stage_label = ttk.Label(self.window_frame, text="Connection", font=("SunValleyBodyFont", 14))
|
||||||
|
self.stage_label.grid(column=0, row=0, pady=40)
|
||||||
|
|
||||||
|
self.stage_label_1 = ttk.Label(self.window_frame, text="Server address", justify=LEFT)
|
||||||
|
self.stage_label_1.grid(column=0, row=1, pady=5, padx=35, sticky=W)
|
||||||
|
|
||||||
|
self.stage_entry_1 = ttk.Entry(self.window_frame)
|
||||||
|
self.stage_entry_1.grid(column=0, row=2, pady=5, padx=35, sticky=W+E)
|
||||||
|
|
||||||
|
self.stage_label_1 = ttk.Label(self.window_frame, text="Personal API key", justify=LEFT)
|
||||||
|
self.stage_label_1.grid(column=0, row=3, pady=5, padx=35, sticky=W)
|
||||||
|
|
||||||
|
self.stage_entry_1 = ttk.Entry(self.window_frame)
|
||||||
|
self.stage_entry_1.grid(column=0, row=4, pady=5, padx=35, sticky=W+E)
|
||||||
|
|
||||||
|
self.stage_button = ttk.Button(self.window_frame, text="Continue", style="Accent.TButton", width=10)
|
||||||
|
self.stage_button.grid(column=0, row=5, pady=40)
|
||||||
|
|
||||||
def acknowledged(self):
|
def acknowledged(self):
|
||||||
configSet(["first_run"], False)
|
configSet(["first_run"], False)
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
def __exit(self):
|
||||||
|
|
||||||
|
decision = messagebox.askyesno(title="Exit confirmation", message="Are you sure? If you exit now, your app will remain unconfigured.")
|
||||||
|
|
||||||
|
if decision is True:
|
||||||
|
self.quit()
|
@ -96,6 +96,18 @@ def get_string_mode() -> Literal["dark", "light"]:
|
|||||||
|
|
||||||
return "dark" if use_dark_mode() is True else "light"
|
return "dark" if use_dark_mode() is True else "light"
|
||||||
|
|
||||||
|
def resize_window(me: Misc, width: int, height: int) -> None:
|
||||||
|
me.window_width = width
|
||||||
|
me.window_height = height
|
||||||
|
|
||||||
|
me.screen_width = me.winfo_screenwidth()
|
||||||
|
me.screen_height = me.winfo_screenheight()
|
||||||
|
|
||||||
|
me.center_x = int(me.screen_width/2 - me.window_width / 2)
|
||||||
|
me.center_y = int(me.screen_height/2 - me.window_height / 2)
|
||||||
|
|
||||||
|
me.geometry(f'{me.window_width}x{me.window_height}+{me.center_x}+{me.center_y}')
|
||||||
|
|
||||||
def set_icon(me: Misc) -> None:
|
def set_icon(me: Misc) -> None:
|
||||||
if osname == "nt":
|
if osname == "nt":
|
||||||
me.iconbitmap(path.join("assets", "favicon.ico"))
|
me.iconbitmap(path.join("assets", "favicon.ico"))
|
||||||
|
Loading…
Reference in New Issue
Block a user