varios
This commit is contained in:
parent
4cdaa4daa2
commit
63884ec541
|
@ -0,0 +1,32 @@
|
||||||
|
import tkinter as tk
|
||||||
|
|
||||||
|
# Crear ventana principal
|
||||||
|
root = tk.Tk()
|
||||||
|
root.geometry("600x400") # Tamaño inicial
|
||||||
|
|
||||||
|
# Configurar la fila y columna principales para que se expandan
|
||||||
|
root.grid_rowconfigure(0, weight=1)
|
||||||
|
root.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
|
# Crear un frame principal y colocarlo en la ventana
|
||||||
|
main_frame = tk.Frame(root, bg="lightgray")
|
||||||
|
main_frame.grid(row=0, column=0, sticky="nsew")
|
||||||
|
|
||||||
|
# Configurar el frame para que se ajuste al tamaño de la ventana
|
||||||
|
main_frame.grid_rowconfigure(0, weight=1)
|
||||||
|
main_frame.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
|
# Crear widgets dentro del frame
|
||||||
|
top_frame = tk.Frame(main_frame, bg="blue")
|
||||||
|
top_frame.grid(row=0, column=0, sticky="nsew")
|
||||||
|
|
||||||
|
bottom_frame = tk.Frame(main_frame, bg="green")
|
||||||
|
bottom_frame.grid(row=1, column=0, sticky="nsew")
|
||||||
|
|
||||||
|
# Configurar tamaños responsivos en el frame principal
|
||||||
|
main_frame.grid_rowconfigure(0, weight=1)
|
||||||
|
main_frame.grid_rowconfigure(1, weight=1)
|
||||||
|
main_frame.grid_columnconfigure(0, weight=1)
|
||||||
|
|
||||||
|
# Ejecutar el bucle de la aplicación
|
||||||
|
root.mainloop()
|
|
@ -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()
|
Loading…
Reference in New Issue