First commit
This commit is contained in:
commit
ae4cf08f6c
|
@ -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()
|
Binary file not shown.
|
@ -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!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue