This commit is contained in:
dez 2024-02-08 11:36:55 +01:00
parent 9a65697801
commit 1d09526210
3 changed files with 29 additions and 18 deletions

View file

@ -1,12 +1,12 @@
import requests
from tqdm import tqdm
from urllib.parse import urlparse
import os
# not exactly ideal solution
def download_from_sourceforge(api_url, file_path):
response = requests.get(api_url, stream=True)
if response.status_code == 200:
total_size = int(response.headers.get('content-length', 0))
block_size = 1024 # 1 KB
@ -15,7 +15,10 @@ def download_from_sourceforge(api_url, file_path):
# Extract the filename from the URL
filename = urlparse(api_url).path.split("/")[-1]
with open(file_path + filename, 'wb') as file:
if not os.path.exists(file_path):
os.makedirs(file_path)
with open(file_path +"/"+ filename, 'wb') as file:
for data in response.iter_content(block_size):
progress_bar.update(len(data))
file.write(data)

View file

@ -6,7 +6,7 @@ from PIL import Image, ImageTk
import download_main
from gui_starfield import StarField
from json_main import save_package
from json_main import save_package, get_default_packages
def run_installer(download_folder_tmp, col_isDark):
global visible_widgets, tab_combobox # Declare tab_combobox as a global variable
@ -27,15 +27,6 @@ def run_installer(download_folder_tmp, col_isDark):
set_appearance_mode("dark")
print("Could not get theme from system.")
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")
def start_install():
switch_to_tab("Tab3")
@ -56,14 +47,21 @@ def run_installer(download_folder_tmp, col_isDark):
# Remove currently visible widgets
for widget in visible_widgets:
widget.pack_forget()
# Create wigets for current tab
# Create widgets for current tab
current_tab = tab_combobox.get()
widget_specs = tabs.get(current_tab, [])
widgets = [create_widget(spec, container) for spec in widget_specs]
for widget in widgets:
widgets = []
for spec in widget_specs:
widget = create_widget(spec, container)
if widget:
widget.pack(pady=20, padx=20)
widgets.append(widget)
return widgets
def create_widget(spec, master):
global progress_bar
if isinstance(spec, tuple):
@ -111,8 +109,8 @@ def run_installer(download_folder_tmp, col_isDark):
"Tab1": [
(CTkButton, {"text": "Next Tab", "command": switch_to_next_tab}),
(CTkButton, {"text": "Previous Tab", "command": switch_to_previous_tab}),
(CTkButton, {"text": "Get Browser package", "command": print_ahoj}),
CTkComboBox,
(CTkButton, {"text": "Get Browser package", "command": get_default_packages}),
(CTkComboBox, {"text": "Theme", "values": ["System", "Light", "Dark"]}),
CTkEntry,
CTkProgressBar,
CTkRadioButton,

View file

@ -1,5 +1,6 @@
import json
import os
import sys
data_location = "./config.json"
@ -112,6 +113,15 @@ def get_package(app):
return {}
def get_default_packages():
if sys.platform == 'win32':
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")
# ######################
# # save package test