darkmode autodetect added

This commit is contained in:
dez 2024-01-31 15:20:10 +01:00
parent 8a78272238
commit a02c6aa1cd
6 changed files with 34 additions and 12 deletions

View file

@ -3,5 +3,6 @@ tkintertable
customtkinter customtkinter
tqdm tqdm
requests requests
darkdetect
nuitka nuitka
pillow pillow

View file

@ -22,8 +22,8 @@ def download_from_sourceforge(api_url, file_path):
else: else:
print(f"Failed to download. Status code: {response.status_code}") print(f"Failed to download. Status code: {response.status_code}")
# Example usage with the provided link # # Example usage with the provided link
sourceforge_api_url = "https://downloads.sourceforge.net/project/sevenzip/7-Zip/19.00/7z1900-x64.exe" # sourceforge_api_url = "https://downloads.sourceforge.net/project/sevenzip/7-Zip/19.00/7z1900-x64.exe"
download_path = "7z1900-x64.exe" # download_path = "7z1900-x64.exe"
download_from_sourceforge(sourceforge_api_url, download_path) # download_from_sourceforge(sourceforge_api_url, download_path)

View file

@ -6,6 +6,7 @@ import json
import json_main import json_main
from download_gitlab import download_and_update from download_gitlab import download_and_update
import download_github import download_github
import donwload_sourceforge
import install_main import install_main
# Global flag to check if the installation should be canceled # Global flag to check if the installation should be canceled
@ -82,6 +83,11 @@ def download_all_packages(progress_bar, progress_label, download_location, insta
tqdm, tqdm,
version version
) )
elif source_type == "sourceforge" or source_type == "raw":
donwload_sourceforge.download_from_sourceforge(
source_info["url"],
os.path.join(download_folder,app_name)
)
# Add other source types as needed # Add other source types as needed
else: else:
progress_label = f"Unsupported source type for {app_name}: {source_type}" progress_label = f"Unsupported source type for {app_name}: {source_type}"

View file

@ -5,6 +5,8 @@ from PIL import Image, ImageTk
import download_main import download_main
from gui_starfield import StarField from gui_starfield import StarField
import darkdetect
from json_main import save_package
def run_installer(download_folder_tmp): def run_installer(download_folder_tmp):
global visible_widgets, tab_combobox # Declare tab_combobox as a global variable global visible_widgets, tab_combobox # Declare tab_combobox as a global variable
@ -16,12 +18,21 @@ def run_installer(download_folder_tmp):
app.minsize(width=800, height=600) app.minsize(width=800, height=600)
app.maxsize(width=800, height=600) app.maxsize(width=800, height=600)
set_default_color_theme("dark-blue") app.isDark = darkdetect.isDark()
set_appearance_mode("dark")
if app.isDark:
set_default_color_theme("dark-blue")
set_appearance_mode("dark")
app.resizable(False, False) app.resizable(False, False)
def print_ahoj(): def print_ahoj():
spitfire_source_info = {
"url": "https://downloads.sourceforge.net/project/spitfire-browser/nightly/components/Browser/win-bin-nighty.zip",
}
#(version, app, source_type, source_info, package_type)
save_package("1.0", "Spitfire", "sourceforge", spitfire_source_info, "browser")
print("ahoj") print("ahoj")
def start_install(): def start_install():
@ -37,7 +48,7 @@ def run_installer(download_folder_tmp):
def display_star_field(container): def display_star_field(container):
global star_field global star_field
star_field = StarField(container, 400, 600) star_field = StarField(container, 400, 600, app.isDark)
star_field.canvas.pack(side="left", fill="y") star_field.canvas.pack(side="left", fill="y")
def create_widgets_for_current_tab(): def create_widgets_for_current_tab():
@ -99,7 +110,7 @@ def run_installer(download_folder_tmp):
"Tab1": [ "Tab1": [
(CTkButton, {"text": "Next Tab", "command": switch_to_next_tab}), (CTkButton, {"text": "Next Tab", "command": switch_to_next_tab}),
(CTkButton, {"text": "Previous Tab", "command": switch_to_previous_tab}), (CTkButton, {"text": "Previous Tab", "command": switch_to_previous_tab}),
CTkCheckBox, (CTkButton, {"text": "Get Browser package", "command": print_ahoj}),
CTkComboBox, CTkComboBox,
CTkEntry, CTkEntry,
CTkProgressBar, CTkProgressBar,

View file

@ -16,7 +16,7 @@ class Star:
self.fill = 0 self.fill = 0
class StarField: class StarField:
def __init__(self, master, width, height, depth=32, num_stars=100): def __init__(self, master, width, height, isDark, depth=32, num_stars=100):
self.master = master self.master = master
self.fov = 180 * math.pi / 180 self.fov = 180 * math.pi / 180
self.view_distance = 0 self.view_distance = 0
@ -27,8 +27,12 @@ class StarField:
self.center_x = width / 2 self.center_x = width / 2
self.center_y = height / 2 self.center_y = height / 2
self.circular_mask_radius = min(self.center_x, self.center_y) * 0.95 self.circular_mask_radius = min(self.center_x, self.center_y) * 0.95
self.canvas = Canvas(master, width=width, height=height, bg="#111111") if isDark:
self.canvas.pack() self.canvas = Canvas(master, width=width, height=height, bg="#111111")
self.canvas.pack()
else:
self.canvas = Canvas(master, width=width, height=height, bg="#FFFFFF")
self.canvas.pack()
# Create a black circle as the background # Create a black circle as the background
self.canvas.create_oval(self.center_x - self.circular_mask_radius, self.canvas.create_oval(self.center_x - self.circular_mask_radius,

View file

@ -1,7 +1,7 @@
import json import json
import os import os
data_location = "./data/config.json" data_location = "./config.json"
def save_first_run(var): def save_first_run(var):
with open(data_location, "r") as json_file: with open(data_location, "r") as json_file: