#!/usr/bin/env python3
from tkinter import *
import tkinter as tk
from tkinter import ttk
from azure_ttk import *
import os
import subprocess

script_dir = os.path.dirname(os.path.abspath(__file__))
application_path = os.path.dirname(script_dir)


print(script_dir)

class App(tk.Tk):
    def __init__(self):
        super().__init__(className="GuideOSNvidiaTools")
        self.title("GuideOS Nvidia Tools")
        self.tk.call("source", TCL_THEME_FILE_PATH)
        self.geometry("450x290")

        self.icon = tk.PhotoImage(
            file=f"/usr/share/icons/hicolor/256x256/apps/primo-di-tutto-logo.png"
        )
        if "dark" in theme_name or "Dark" in theme_name:
            self.tk.call("set_theme", "dark")
        else:
            self.tk.call("set_theme", "light")

        # Erster Frame (oben)
        frame1 = ttk.LabelFrame(self, text="Aus dem Repository (Empfohlen)", padding=10)
        frame1.pack(fill="x", padx=10, pady=5)

        self.label1 = ttk.Label(frame1, text="Installiert den Treiber aus dem Debian Repository.")
        self.label1.pack(pady=5)

        btn1 = ttk.Button(frame1, text="Öffen", command=self.standard,style="Accent.TButton")
        btn1.pack(fill="x")

        # Zweiter Frame (unten)
        frame2 = ttk.LabelFrame(self, text="Direkt von Nvidia", padding=10)
        frame2.pack(fill="x", padx=10, pady=5)

        self.label2 = ttk.Label(frame2, text="Ist nur für fortgeschrittene Nutzer geeignet und sollte nur verwendet werden, wenn der Treiber aus dem Repository nicht funktioniert.",wraplength=400)
        self.label2.pack(pady=5)

        btn2 = ttk.Button(frame2, text="Öffnen", command=self.expert)
        btn2.pack(fill="x")

    def standard(self):
        subprocess.run([os.path.join(script_dir, "standard.sh")], check=True)

    def expert(self):
        subprocess.run([os.path.join(script_dir, "expert.sh")], check=True)


if __name__ == "__main__":
    app = App()
    app.mainloop()
