From c162cd7ce8762cd655e2db996e5f60c56c092667 Mon Sep 17 00:00:00 2001 From: Juanjo Date: Tue, 5 Nov 2024 19:02:14 +0100 Subject: [PATCH] ventanas --- windows.py | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 windows.py diff --git a/windows.py b/windows.py new file mode 100644 index 0000000..05ffa49 --- /dev/null +++ b/windows.py @@ -0,0 +1,101 @@ +import tkinter as tk +from tkinter import messagebox +from tkinter import Menu +from ficheros import persistenciaFile +from bbdd import guardar +from scraping.busca import MiScraping + +def option1(): + + cadena = "https://www.google.com" + guardar.guardar_enlace_en_bd(cadena) + + MiObjScraping = MiScraping("https://ieslamar.org") + MiObjScraping.start() + MiObjScraping.join() + links = MiObjScraping.get_links() + for link in links: + text.insert(tk.END, link + "\n") + + +def option2(): + messagebox.showinfo("Opción 2", "Has seleccionado la Opción 2") + +def option3(): + messagebox.showinfo("Opción 3", "Has seleccionado la Opción 3") + +def option4(): + messagebox.showinfo("Opción 4", "Has seleccionado la Opción 4") + +# Crear la ventana principal de tamaño fijo +root = tk.Tk() +root.title("Menú de Opciones") +root.geometry("1000x500") +root.resizable(False, False) + +# Crear el menú +menu_bar = tk.Menu(root) + +# Agregar las opciones al menú +file_menu = Menu(menu_bar, tearoff=0) +file_menu.add_command(label="Nuevo") +file_menu.add_command(label="Abrir") +file_menu.add_separator() +file_menu.add_command(label="Salir", command=root.quit) + +help_menu = Menu(menu_bar, tearoff=0) +help_menu.add_command(label="Acerca de") + +menu_bar.add_cascade(label="Archivo", menu=file_menu) +menu_bar.add_cascade(label="Ayuda", menu=help_menu) + +menu_bar.add_command(label="Scraping", command=option1) +menu_bar.add_command(label="Guardar enlaces", command=option2) +menu_bar.add_command(label="Guardar páginas", command=option3) +menu_bar.add_command(label="Contenido web", command=option4) + +# Configurar la barra de menú en la ventana +root.config(menu=menu_bar) + +# Pie de ventana + +footer = tk.Label(root, text="Pie de ventana - Aquí puedes mostrar mensajes o estado", bd=1, relief=tk.SUNKEN, anchor="w") +footer.pack(side=tk.BOTTOM, fill=tk.X) + +# Crear los frames principales +# frame top, alineación izquierda + +frame_top = tk.Frame(root, bg="lightyellow", width=1000, height=50) +frame_left = tk.Frame(root, bg="lightblue", width=450, height=400) +frame_right = tk.Frame(root, bg="lightgreen", width=450, height=400) +frame_bottom = tk.Frame(root, bg="lightcoral", width=1000, height=50) + +# Ubicar los frames en la ventana de forma absoluta +frame_top.pack(side="top") +frame_bottom.pack(side="bottom") +frame_left.pack(side="left") +frame_right.pack(side="left") + + +# Crear boton opcion 1 en frame1 +button1 = tk.Button(frame_left, text="Scraping", command=option1) +button1.pack() + +label = tk.Label(frame_bottom, text="Enlaces encontrados", bg=frame_bottom['bg']) +label.pack() + + +# crear un cuadro de texto de varias lineas +text = tk.Text(frame_left) +text.pack() + + +button2 = tk.Button(frame_right, text="Contenido", command=option4) +button2.pack() + +contenido = tk.Text(frame_right) +contenido.pack() + + +# Iniciar el bucle principal de la aplicación +root.mainloop() \ No newline at end of file