Compare commits
No commits in common. "63884ec5411bc939f0aad3d0da1776485bf8f5be" and "ad78ce307a0d05ceb1a6eaeca7f5d64177647d2b" have entirely different histories.
63884ec541
...
ad78ce307a
|
@ -1,37 +0,0 @@
|
||||||
import tkinter as tk
|
|
||||||
from tkinter import ttk
|
|
||||||
from matplotlib.figure import Figure
|
|
||||||
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
|
||||||
|
|
||||||
# Función para crear el gráfico de barras
|
|
||||||
def plot_barchart():
|
|
||||||
# Datos de ejemplo
|
|
||||||
categories = ['A', 'B', 'C', 'D', 'E']
|
|
||||||
values = [5, 7, 3, 8, 6]
|
|
||||||
|
|
||||||
# Limpiamos la figura antes de redibujar el gráfico
|
|
||||||
fig.clear()
|
|
||||||
ax = fig.add_subplot(111)
|
|
||||||
ax.bar(categories, values, color='skyblue')
|
|
||||||
ax.set_title("Gráfico de Barras de Ejemplo")
|
|
||||||
ax.set_xlabel("Categorías")
|
|
||||||
ax.set_ylabel("Valores")
|
|
||||||
|
|
||||||
# Actualizamos el canvas para mostrar el gráfico
|
|
||||||
canvas.draw()
|
|
||||||
|
|
||||||
# Configuración de la ventana principal
|
|
||||||
root = tk.Tk()
|
|
||||||
root.title("Gráfico de Barras con Tkinter y Matplotlib")
|
|
||||||
root.geometry("1000x900")
|
|
||||||
|
|
||||||
# Creamos una figura de matplotlib
|
|
||||||
fig = Figure(figsize=(5, 4), dpi=100)
|
|
||||||
canvas = FigureCanvasTkAgg(fig, master=root)
|
|
||||||
canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
|
|
||||||
|
|
||||||
# Botón para mostrar el gráfico
|
|
||||||
plot_button = ttk.Button(root, text="Mostrar Gráfico de Barras", command=plot_barchart)
|
|
||||||
plot_button.pack(side=tk.BOTTOM, pady=20)
|
|
||||||
|
|
||||||
root.mainloop()
|
|
|
@ -1,32 +0,0 @@
|
||||||
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()
|
|
|
@ -1,101 +0,0 @@
|
||||||
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