This commit is contained in:
Juanjo 2024-11-05 19:02:14 +01:00
parent 9769c90995
commit c162cd7ce8
1 changed files with 101 additions and 0 deletions

101
windows.py Normal file
View File

@ -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()