cleanup
This commit is contained in:
parent
f3ffdb9d6a
commit
87a09ba29f
5 changed files with 37 additions and 67 deletions
|
@ -1,4 +1,5 @@
|
|||
import threading
|
||||
import os
|
||||
from customtkinter import *
|
||||
from tkinter import PhotoImage
|
||||
from PIL import Image, ImageTk
|
||||
|
@ -6,42 +7,8 @@ from PIL import Image, ImageTk
|
|||
import download_main
|
||||
from gui_starfield import StarField
|
||||
from json_main import save_package
|
||||
from theme_ctk_auto import generate_theme_json
|
||||
|
||||
def apply_theme(app, col_background, col_theme, is_dark):
|
||||
|
||||
if is_dark:
|
||||
set_default_color_theme("dark-blue")
|
||||
set_appearance_mode("dark")
|
||||
else:
|
||||
set_default_color_theme("blue")
|
||||
set_appearance_mode("white")
|
||||
|
||||
generate_theme_json(col_theme, is_dark)
|
||||
set_default_color_theme("./theme.json")
|
||||
|
||||
# # Apply background color to the app
|
||||
# app.configure(bg=f"#{col_background[0]:02x}{col_background[1]:02x}{col_background[2]:02x}")
|
||||
|
||||
# # Customize individual widget colors
|
||||
# CLabel.set_default("bg", f"#{col_background[0]:02x}{col_background[1]:02x}{col_background[2]:02x}")
|
||||
# CLabel.set_default("fg", f"#{col_theme[0]:02x}{col_theme[1]:02x}{col_theme[2]:02x}")
|
||||
|
||||
# CButton.set_default("bg", f"#{col_theme[0]:02x}{col_theme[1]:02x}{col_theme[2]:02x}")
|
||||
# CButton.set_default("fg", f"#{col_background[0]:02x}{col_background[1]:02x}{col_background[2]:02x}")
|
||||
|
||||
# CCombobox.set_default("bg", f"#{col_theme[0]:02x}{col_theme[1]:02x}{col_theme[2]:02x}")
|
||||
# CCombobox.set_default("fg", f"#{col_background[0]:02x}{col_background[1]:02x}{col_background[2]:02x}")
|
||||
|
||||
# # Set dark mode specific configurations
|
||||
# if is_dark:
|
||||
# # Example: Set dark mode specific configurations
|
||||
# CLabel.set_default("font", ("Arial", 12, "bold"))
|
||||
# CButton.set_default("font", ("Arial", 12, "bold"))
|
||||
# # Add more configurations as needed for dark mode
|
||||
|
||||
|
||||
def run_installer(download_folder_tmp, col_background, col_theme, col_isDark):
|
||||
def run_installer(download_folder_tmp, col_isDark):
|
||||
global visible_widgets, tab_combobox # Declare tab_combobox as a global variable
|
||||
|
||||
app = CTk()
|
||||
|
@ -53,7 +20,7 @@ def run_installer(download_folder_tmp, col_background, col_theme, col_isDark):
|
|||
|
||||
app.resizable(False, False)
|
||||
|
||||
apply_theme(app, col_background, col_theme, col_isDark)
|
||||
set_default_color_theme(os.path.join(download_folder_tmp,"./theme.json"))
|
||||
|
||||
def print_ahoj():
|
||||
spitfire_source_info = {
|
||||
|
|
|
@ -6,20 +6,6 @@ import zipfile
|
|||
import certifi
|
||||
import ssl
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
def get_temp_folder():
|
||||
# Get the current user's temporary directory
|
||||
temp_dir = tempfile.gettempdir()
|
||||
|
||||
# Create a subdirectory inside the temporary directory
|
||||
user_temp_folder = os.path.join(temp_dir, 'SpitfireBrowserTmp')
|
||||
|
||||
# Create the directory if it doesn't exist
|
||||
if not os.path.exists(user_temp_folder):
|
||||
os.makedirs(user_temp_folder)
|
||||
|
||||
return user_temp_folder
|
||||
|
||||
|
||||
def download_file(url, destination, progress_callback=None, label_callback=None):
|
||||
|
@ -85,9 +71,7 @@ def set_path_variable(download_path):
|
|||
print(f"Added PATH: {output_string_unique}")
|
||||
|
||||
|
||||
def get_deps_win():
|
||||
|
||||
download_path = get_temp_folder()
|
||||
def get_deps_win(download_path):
|
||||
|
||||
dll_url = 'https://downloads.sourceforge.net/project/spitfire-browser/nightly/components/GTK4/'
|
||||
|
||||
|
|
|
@ -1,14 +1,32 @@
|
|||
from init_win import get_deps_win
|
||||
from theme_win import get_theme_win
|
||||
from gui_main import run_installer
|
||||
from theme_ctk_auto import generate_theme_json
|
||||
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
def get_temp_folder():
|
||||
# Get the current user's temporary directory
|
||||
temp_dir = tempfile.gettempdir()
|
||||
|
||||
# Create a subdirectory inside the temporary directory
|
||||
user_temp_folder = os.path.join(temp_dir, 'SpitfireBrowserTmp')
|
||||
|
||||
# Create the directory if it doesn't exist
|
||||
if not os.path.exists(user_temp_folder):
|
||||
os.makedirs(user_temp_folder)
|
||||
|
||||
return user_temp_folder
|
||||
|
||||
def main_win():
|
||||
dow_path = "./tmp"
|
||||
dow_path = get_temp_folder()
|
||||
col_background = None
|
||||
col_theme = None
|
||||
is_dark = None
|
||||
|
||||
dow_path = get_deps_win()
|
||||
get_deps_win(dow_path)
|
||||
col_background, col_theme, is_dark = get_theme_win()
|
||||
generate_theme_json(dow_path, col_theme, is_dark)
|
||||
|
||||
run_installer(dow_path, col_background, col_theme, is_dark)
|
||||
run_installer(dow_path, is_dark)
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
def rgb_to_hex(rgb):
|
||||
"""
|
||||
|
@ -44,7 +45,7 @@ def adjust_brightness_based_on_luminance(color, adjustment_percent):
|
|||
|
||||
return rgb_to_hex(adjusted_color)
|
||||
|
||||
def generate_theme_json(col_theme, is_dark):
|
||||
def generate_theme_json(path, col_theme, is_dark):
|
||||
# Define colors based on is_dark
|
||||
if is_dark:
|
||||
bg_color = ["gray17", "gray20"]
|
||||
|
@ -296,8 +297,8 @@ def generate_theme_json(col_theme, is_dark):
|
|||
},
|
||||
"DropdownMenu": {
|
||||
"fg_color": bg_color,
|
||||
"hover_color": bg_col_theme,
|
||||
"text_color": txt_col_theme
|
||||
"hover_color": disabled_text_col,
|
||||
"text_color": text_color
|
||||
},
|
||||
"CTkFont": {
|
||||
"macOS": {
|
||||
|
@ -342,7 +343,7 @@ def generate_theme_json(col_theme, is_dark):
|
|||
"harmony differential": None
|
||||
}
|
||||
|
||||
with open("./theme.json", "w") as json_file:
|
||||
with open(os.path.join(path + "./theme.json"), "w") as json_file:
|
||||
json.dump(theme_data, json_file, indent=2)
|
||||
|
||||
# Example use
|
||||
|
|
|
@ -62,10 +62,10 @@ def get_theme_win():
|
|||
|
||||
return col_background, col_theme, is_dark
|
||||
|
||||
# Example use
|
||||
if __name__ == "__main__":
|
||||
col_background, col_theme, is_dark = get_theme_win()
|
||||
print(f"---------------")
|
||||
print(f"Background Color: RGB{col_background}")
|
||||
print(f"Theme Color: RGB{col_theme}")
|
||||
print(f"Dark Mode: {'Enabled' if is_dark else 'Disabled'}")
|
||||
# # Example use
|
||||
# if __name__ == "__main__":
|
||||
# col_background, col_theme, is_dark = get_theme_win()
|
||||
# print(f"---------------")
|
||||
# print(f"Background Color: RGB{col_background}")
|
||||
# print(f"Theme Color: RGB{col_theme}")
|
||||
# print(f"Dark Mode: {'Enabled' if is_dark else 'Disabled'}")
|
||||
|
|
Reference in a new issue