Added top menubar

This commit is contained in:
Dennis Eckerskorn 2024-12-02 09:07:32 +01:00
parent 80948b2bdd
commit 3804bb332d
2 changed files with 25 additions and 4 deletions

View File

@ -25,13 +25,15 @@ class CenteredWindow(ctk.CTk):
self.geometry(f"{window_width}x{window_height}+{position_x}+{position_y}") self.geometry(f"{window_width}x{window_height}+{position_x}+{position_y}")
#Configura la ventana (fuera del constructor) #Configura la ventana
self.configure_window() self.configure_window()
def configure_window(self): def configure_window(self):
# Configuraciones adicionales: # Configuracion de la ventana:
self.configure(bg_color="lightgray") self.configure(bg_color="lightgray")
self.create_menuBar()
# Frame para organizar los botones: # Frame para organizar los botones:
button_frame = ctk.CTkFrame(self) button_frame = ctk.CTkFrame(self)
button_frame.pack(side=ctk.TOP, anchor=ctk.NW, padx=20, pady=20) button_frame.pack(side=ctk.TOP, anchor=ctk.NW, padx=20, pady=20)
@ -54,6 +56,25 @@ class CenteredWindow(ctk.CTk):
def create_menuBar(self):
menu_bar = ctk.CTkFrame(self, height=25, fg_color="lightgray")
menu_bar.pack(side=ctk.TOP, fill=ctk.X)
#Botones del menuBar:
# Agregar botones de menú
menus = ["Procesos", "T2.Threads", "T3.Sockets", "T4.Servicios", "T5.Seguridad", "Configuración"]
for menu in menus:
btn = ctk.CTkButton(
menu_bar,
text=menu,
command=lambda m=menu: self.on_menu_click(m),
width=100,
height=20,
fg_color="blue",
hover_color="lightblue"
)
btn.pack(side=ctk.LEFT, padx=5, pady=5)
def open_chrome(self): def open_chrome(self):
try: try:
webbrowser.get('chrome').open('https://google.es') webbrowser.get('chrome').open('https://google.es')
@ -85,8 +106,8 @@ class CenteredWindow(ctk.CTk):
def on_button_click(self): def on_menu_click(self, menu_name):
print("¡Botón clickeado!") self.text_area.insert(ctk.END, f"Menú seleccionado: {menu_name}\n")