commit ae4cf08f6cde280c465e1a3dd9a93dc30021a4ac Author: DennisEckerskorn Date: Tue Nov 26 18:43:42 2024 +0100 First commit diff --git a/main.py b/main.py new file mode 100644 index 0000000..8e961f3 --- /dev/null +++ b/main.py @@ -0,0 +1,11 @@ +from ui import CenteredWindow + +def main(): + # Crear una instancia de la ventana centrada + app = CenteredWindow() + + # Ejecutar la ventana + app.mainloop() + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ui/__pycache__/CenteredWindow.cpython-312.pyc b/ui/__pycache__/CenteredWindow.cpython-312.pyc new file mode 100644 index 0000000..8f1030f Binary files /dev/null and b/ui/__pycache__/CenteredWindow.cpython-312.pyc differ diff --git a/ui/centered_window.py b/ui/centered_window.py new file mode 100644 index 0000000..e895565 --- /dev/null +++ b/ui/centered_window.py @@ -0,0 +1,39 @@ +import customtkinter as ctk + +class CenteredWindow(ctk.CTk): + def __init__(self, title="MultiApp", width_percentage=0.8, height_percentage=0.8): + # Inicializacion de la clase: + super().__init__() + + # Titulo de la ventana: + self.title(title) + + # Obtener la resolucion de la pantalla: + screen_width = self.winfo.screenwidth() + screen_height = self.winfo.screenheight() + + # Calcula el tamaño de la ventana según procentaje de la pantalla: + window_width = int(screen_width * width_percentage) + window_height = int(screen_height * height_percentage) + + # Calcular la posicion para centrar la ventana: + position_x = (screen_width - window_width) // 2 + position_y = (screen_height - window_height) // 2 + + self.geometry(f"{window_width}x{window_height}+{position_x}+{position_y}") + + self.configure_window() + + def configure_window(self): + # Configuraciones adicionales: + self.configure(bg_color="lightgray") + # Ejemplo de añadir un botón + btn = ctk.CTkButton(self, text="Haz clic aquí", command=self.on_button_click) + btn.pack(pady=20) + + def on_button_click(self): + print("¡Botón clickeado!") + + + +