import webbrowser

import customtkinter
from customtkinter import CTkToplevel


class AboutWindow:
    def __init__(self, app):
        self.app = app

        self.window = CTkToplevel(app.root)
        self.window.title("À propos")
        self.window.geometry("600x300")
        self.window.protocol("WM_DELETE_WINDOW", self.on_closing)

        link_gesture_drawing = customtkinter.CTkLabel(self.window, text="Open Source alternative to GestureDrawing!")
        link_gesture_drawing.pack()
        link_gesture_drawing.bind("<Button-1>",
                                  lambda e: self.open_link("https://cubebrush.co/advanches/products/d9q6yq/gesturedrawing"))

        link_shikiryu = customtkinter.CTkLabel(self.window, text="by Shikiryu")
        link_shikiryu.pack()
        link_shikiryu.bind("<Button-1>", lambda e: self.open_link("https://shikiryu.com"))

    @staticmethod
    def open_link(url):
        webbrowser.open_new(url)

    def on_closing(self):
        self.window.destroy()
