import tkinter as tk
import os, sys

class Desktop:
    def __init__(self, root):
        self.root = root
        self.settings = {"theme": "GrimOS"}
    def save_and_quit(self):
        print("save and quit called!")

class AppManager:
    def __init__(self, desktop):
        self.desktop = desktop

root = tk.Tk()
desktop = Desktop(root)
app_manager = AppManager(desktop)

window = tk.Frame(root)
window.pack()

import apps.parametres.app as app
app.start(window, app_manager=app_manager)

# Find apply btn
for c in window.winfo_children()[0].winfo_children():
    if isinstance(c, tk.Frame):
        for cc in c.winfo_children():
            if isinstance(cc, tk.Button) and cc.cget("text") == "Appliquer":
                print("Invoking button")
                cc.invoke()

print("Restart requested:", getattr(desktop, 'restart_requested', False))
