responsive
This commit is contained in:
parent
7356c7d545
commit
0faaed020b
|
@ -1 +1,23 @@
|
||||||
|
# Ignorar archivos de Python compilados
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*.pyo
|
||||||
|
|
||||||
|
# Configuración de entorno virtual
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
|
||||||
|
# Configuración de IDEs y editores
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Archivos de configuración y cachés
|
||||||
|
*.log
|
||||||
|
*.sqlite3
|
||||||
|
|
||||||
|
bbdd/__pycache__/__init__.cpython-312.pyc
|
||||||
|
bbdd/__pycache__/__init__.cpython-312.pyc
|
||||||
|
ficheros/__pycache__/__init__.cpython-312.pyc
|
||||||
|
ficheros/__pycache__/persistenciaFile.cpython-312.pyc
|
||||||
|
scraping/__pycache__/__init__.cpython-312.pyc
|
||||||
|
scraping/__pycache__/busca.cpython-312.pyc
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
58
main.py
58
main.py
|
@ -1,20 +1,56 @@
|
||||||
from ficheros import persistenciaFile
|
from ficheros import persistenciaFile
|
||||||
from bbdd import guardar
|
from bbdd import guardar
|
||||||
from scraping.busca import MiScraping
|
from scraping.busca import MiScraping
|
||||||
|
from tkinter import Tk, Entry, Button
|
||||||
|
|
||||||
|
# creamos una ventana con 4 botones y un campo de texto donde se pedirá una url
|
||||||
|
# al pulsar el primer botón se guardará la url en la base de datos
|
||||||
|
# al pulsar el segundo botón se realizará un scraping de la url y se mostrarán los enlaces
|
||||||
|
# al pulsar el tercer botón se guardará un texto en un fichero
|
||||||
|
# al pulsar el cuarto botón se leerá el fichero y se mostrará el contenido en un cuadro de texto
|
||||||
|
|
||||||
|
def guardando (texto):
|
||||||
|
""" guardar.guardar_enlace_en_bd(texto)
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def Scrapiando(url):
|
||||||
|
"""
|
||||||
|
MiObjScraping = MiScraping(url)
|
||||||
|
MiObjScraping.start()
|
||||||
|
MiObjScraping.join()
|
||||||
|
links = MiObjScraping.get_links()
|
||||||
|
salida = Entry(ventana, width=50)
|
||||||
|
for link in links:
|
||||||
|
# colocar el enlace en en cuadro de texto de varias líneas
|
||||||
|
salida.insert(0, link)
|
||||||
|
salida.pack()
|
||||||
|
|
||||||
|
texto = "Este es un ejemplo de texto."
|
||||||
|
nombre_fichero = "ejemplo.txt"
|
||||||
|
persistenciaFile.guardar_texto_en_fichero(texto, nombre_fichero) """
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cadena = "https://www.google.com"
|
#creacion de la ventana
|
||||||
guardar.guardar_enlace_en_bd(cadena)
|
ventana = Tk()
|
||||||
|
ventana.title("Ejemplo de aplicación")
|
||||||
|
ventana.geometry("800x400")
|
||||||
|
#creacion de los elementos de la ventana
|
||||||
|
|
||||||
MiObjScraping = MiScraping("https://ieslamar.org")
|
texto = Entry(ventana, width=50)
|
||||||
MiObjScraping.start()
|
# ponemos un texto por defecto en el campo de text
|
||||||
MiObjScraping.join()
|
texto.insert(0, "http://google.com")
|
||||||
links = MiObjScraping.get_links()
|
texto.pack()
|
||||||
for link in links:
|
|
||||||
print(link)
|
|
||||||
|
|
||||||
texto = "Este es un ejemplo de texto."
|
boton1 = Button(ventana, text="Guardar enlace en BD", command=guardando(texto))
|
||||||
nombre_fichero = "ejemplo.txt"
|
boton1.pack()
|
||||||
persistenciaFile.guardar_texto_en_fichero(texto, nombre_fichero)
|
|
||||||
|
boton2 = Button(ventana, text="Scraping", command=Scrapiando(texto))
|
||||||
|
boton2.pack()
|
||||||
|
|
||||||
|
boton3 = Button(ventana, text="Guardar en fichero", command=Scrapiando(texto))
|
||||||
|
boton3.pack()
|
||||||
|
|
||||||
|
|
|
@ -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()
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue