try:
    from suzaku import *
except:
    raise ModuleNotFoundError(
        "Suzaku module not found! Install suzaku or run with python3 -m suzaku in parent dir."
    )
import glfw
import skia

if __name__ == "__main__":
    # 修改主窗口创建代码
    app = SkApp(is_get_context_on_focus=True, is_always_update=True)
    # print(glfw.default_window_hints())

    def create1window():
        window = SkWindow(
            anti_alias=True,
            parent=None,
            title="Suzaku GUI",
            size=(280, 550),
        )
        # window.bind("delete_window", lambda _: window.can_be_close(False))
        window.apply_theme(SkTheme.INTERNAL_THEMES["default.dark"])
        # window.apply_theme(default_theme)
        # window.hide()
        window.bind("drop", lambda evt: print("drop", evt))

        frame = SkCard(window)
        # frame.allowed_out_of_bounds = True

        SkTextButton(frame, text="This is a SkTextButton").box(padx=10, pady=(10, 0))
        SkTextButton(frame, text="Ask Notice", command=window.hongwen).box(
            padx=10, pady=(10, 0)
        )
        SkText(frame, text="This is a SkLabel").box(padx=10, pady=(10, 0))
        SkCheckItem(frame, text="这是一个复选框").box(padx=10, pady=10)

        var = SkStringVar()
        SkLineInput(frame, placeholder="无边框输入框", textvariable=var).box(
            padx=10, pady=(10, 0)
        )

        SkEntry(frame, placeholder="数值绑定", textvariable=var).box(
            padx=10, pady=(10, 0)
        )
        SkEntry(frame, placeholder="数值绑定", textvariable=var).box(
            padx=10, pady=(10, 0)
        )
        SkText(frame, textvariable=var).box(padx=10, pady=(10, 0))

        frame2 = SkCard(frame)
        SkTextButton(frame2, text="Create 1 New window", command=create1window).box(
            padx=10, pady=(10, 0)
        )
        frame2.box(padx=10, pady=10, expand=True)

        frame.box(padx=10, pady=10, expand=True)

        SkTextButton(window, text="Close the window", command=window.destroy).box(
            side="bottom"
        )

    create1window()

    app.run()
