Welcome screen added
This commit is contained in:
parent
1be317898f
commit
e97c218ab3
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.2 KiB |
BIN
assets/welcome.gif
Normal file
BIN
assets/welcome.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
@ -10,6 +10,7 @@ from classes.frames.devices import FrameDevices
|
|||||||
from classes.frames.saves import FrameSaves
|
from classes.frames.saves import FrameSaves
|
||||||
from classes.frames.settings import FrameSettings
|
from classes.frames.settings import FrameSettings
|
||||||
from classes.frames.errors import FrameErrorConnection, FrameErrorSavesFolder, FrameErrorUnconfigured
|
from classes.frames.errors import FrameErrorConnection, FrameErrorSavesFolder, FrameErrorUnconfigured
|
||||||
|
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, use_dark_mode
|
from modules.utils import configGet, get_string_mode, use_dark_mode
|
||||||
|
|
||||||
@ -93,6 +94,10 @@ class App(ThemedTk):
|
|||||||
# self.setup_button.grid(column=1, row=1, padx=9, pady=9, sticky=N)
|
# self.setup_button.grid(column=1, row=1, padx=9, pady=9, sticky=N)
|
||||||
# return
|
# return
|
||||||
|
|
||||||
|
if configGet("first_run") is True:
|
||||||
|
self.welcome_window = ToplevelWelcome(self)
|
||||||
|
self.welcome_window.grab_set()
|
||||||
|
|
||||||
self.frame_sidebar = ThemedFrame(self)
|
self.frame_sidebar = ThemedFrame(self)
|
||||||
self.frame_sidebar.grid(column=0, row=0, columnspan=1, sticky=N+S+W+E)
|
self.frame_sidebar.grid(column=0, row=0, columnspan=1, sticky=N+S+W+E)
|
||||||
|
|
||||||
|
40
classes/custom/image_label.py
Normal file
40
classes/custom/image_label.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import tkinter as tk
|
||||||
|
from PIL import Image, ImageTk
|
||||||
|
from itertools import count, cycle
|
||||||
|
|
||||||
|
class ImageLabel(tk.Label):
|
||||||
|
"""
|
||||||
|
A Label that displays images, and plays them if they are gifs
|
||||||
|
:im: A PIL Image instance or a string filename
|
||||||
|
"""
|
||||||
|
def load(self, im):
|
||||||
|
if isinstance(im, str):
|
||||||
|
im = Image.open(im)
|
||||||
|
frames = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
for i in count(1):
|
||||||
|
frames.append(ImageTk.PhotoImage(im.copy()))
|
||||||
|
im.seek(i)
|
||||||
|
except EOFError:
|
||||||
|
pass
|
||||||
|
self.frames = cycle(frames)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.delay = im.info['duration']
|
||||||
|
except:
|
||||||
|
self.delay = 100
|
||||||
|
|
||||||
|
if len(frames) == 1:
|
||||||
|
self.config(image=next(self.frames))
|
||||||
|
else:
|
||||||
|
self.next_frame()
|
||||||
|
|
||||||
|
def unload(self):
|
||||||
|
self.config(image=None)
|
||||||
|
self.frames = None
|
||||||
|
|
||||||
|
def next_frame(self):
|
||||||
|
if self.frames:
|
||||||
|
self.config(image=next(self.frames))
|
||||||
|
self.after(self.delay, self.next_frame)
|
@ -1,5 +1,4 @@
|
|||||||
from ttkthemes import ThemedTk
|
from tkinter import Misc
|
||||||
from typing import Union
|
|
||||||
import sv_ttk
|
import sv_ttk
|
||||||
from tkinter.ttk import Frame
|
from tkinter.ttk import Frame
|
||||||
|
|
||||||
@ -7,7 +6,7 @@ from modules.utils import get_string_mode
|
|||||||
|
|
||||||
class ThemedFrame(Frame):
|
class ThemedFrame(Frame):
|
||||||
|
|
||||||
def __init__(self, master: ThemedTk, **kwargs) -> None:
|
def __init__(self, master: Misc, **kwargs) -> None:
|
||||||
|
|
||||||
super().__init__(master, **kwargs)
|
super().__init__(master, **kwargs)
|
||||||
|
|
||||||
|
13
classes/custom/themed_toplevel.py
Normal file
13
classes/custom/themed_toplevel.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from tkinter import Misc, Toplevel
|
||||||
|
import sv_ttk
|
||||||
|
from modules.theme_titlebar import theme_title_bar
|
||||||
|
|
||||||
|
from modules.utils import get_string_mode, use_dark_mode
|
||||||
|
|
||||||
|
class ThemedToplevel(Toplevel):
|
||||||
|
|
||||||
|
def __init__(self, master: Misc, **kwargs) -> None:
|
||||||
|
|
||||||
|
super().__init__(master, **kwargs)
|
||||||
|
|
||||||
|
sv_ttk.set_theme(get_string_mode())
|
60
classes/toplevel/welcome.py
Normal file
60
classes/toplevel/welcome.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
from os import path
|
||||||
|
from tkinter import CENTER, END, E, Image, IntVar, N, S, PhotoImage, Toplevel, W, messagebox, ttk
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import sv_ttk
|
||||||
|
from classes.custom.image_label import ImageLabel
|
||||||
|
|
||||||
|
from classes.custom.themed_toplevel import ThemedToplevel
|
||||||
|
from modules.logger import logger
|
||||||
|
from modules.theme_titlebar import theme_title_bar
|
||||||
|
from modules.utils import configGet, configSet, use_dark_mode
|
||||||
|
|
||||||
|
|
||||||
|
class ToplevelWelcome(ThemedToplevel):
|
||||||
|
|
||||||
|
def __init__(self, parent):
|
||||||
|
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.window_width = 380
|
||||||
|
self.window_height = 350
|
||||||
|
|
||||||
|
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("Welcome to Stardew Sync")
|
||||||
|
self.geometry(f'{self.window_width}x{self.window_height}+{self.center_x}+{self.center_y}')
|
||||||
|
|
||||||
|
self.resizable(False, True)
|
||||||
|
|
||||||
|
sv_ttk.init_theme(self)
|
||||||
|
|
||||||
|
if use_dark_mode():
|
||||||
|
theme_title_bar(self, mode="dark")
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
self.iconbitmap(path.join("assets", "favicon.ico"))
|
||||||
|
self.focus_set()
|
||||||
|
|
||||||
|
self.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
|
self.welcome_pic = ImageLabel(self)
|
||||||
|
self.welcome_pic.grid(column=0, row=0, pady=20)
|
||||||
|
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.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.grid(column=0, row=2)
|
||||||
|
|
||||||
|
self.welcome_button = ttk.Button(self, text="Begin", style="Accent.TButton", width=10, command=self.acknowledged)
|
||||||
|
self.welcome_button.grid(column=0, row=3, pady=20)
|
||||||
|
|
||||||
|
def acknowledged(self):
|
||||||
|
configSet(["first_run"], False)
|
||||||
|
self.destroy()
|
@ -4,5 +4,6 @@
|
|||||||
"allow_self_signed": false,
|
"allow_self_signed": false,
|
||||||
"saves_location": null,
|
"saves_location": null,
|
||||||
"dark_mode": false,
|
"dark_mode": false,
|
||||||
"dark_mode_auto": true
|
"dark_mode_auto": true,
|
||||||
|
"first_run": true
|
||||||
}
|
}
|
16
main.py
16
main.py
@ -1,4 +1,20 @@
|
|||||||
|
from os import path
|
||||||
from classes.app import App
|
from classes.app import App
|
||||||
|
from modules.utils import jsonSave
|
||||||
|
|
||||||
|
if not path.exists("config.json"):
|
||||||
|
jsonSave(
|
||||||
|
{
|
||||||
|
"address": None,
|
||||||
|
"apikey": None,
|
||||||
|
"allow_self_signed": False,
|
||||||
|
"saves_location": None,
|
||||||
|
"dark_mode": False,
|
||||||
|
"dark_mode_auto": True,
|
||||||
|
"first_run": True
|
||||||
|
},
|
||||||
|
"config.json"
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user