-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import tkinter as tk | ||
from PIL import Image, ImageTk | ||
|
||
class Cell: | ||
def __init__(self, title, path, desc): | ||
## Constructor. | ||
self.title = title | ||
self.path = path | ||
self.desc = desc | ||
## Reescalamos una imagen dándole nuevos valores al ancho y al alto. | ||
foto = Image.open(self.path) | ||
foto_red = foto.resize((100, 100), Image.Resampling.LANCZOS) | ||
self.image_tk = ImageTk.PhotoImage(foto_red) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from tkinter import ttk | ||
import tkinter as tk | ||
from PIL import Image, ImageTk | ||
from cell import Cell | ||
|
||
def detailWindow(cell): | ||
|
||
## Creamos una ventana emergente con su respectivo título. | ||
root = tk.Toplevel() | ||
root.title("Descripción") | ||
|
||
## Distintos label destinados a mostrar el título, la imagen y la descripción. | ||
label1 = ttk.Label(root, text = cell.title) | ||
label2 = ttk.Label(root, image = cell.image_tk) | ||
label3 = ttk.Label(root, text = cell.desc) | ||
label1.pack() | ||
label2.pack() | ||
label3.pack() | ||
|
||
## Lanzamos el bucle principal. | ||
root.mainloop() | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from tkinter import Tk | ||
from window import MainWindow | ||
|
||
if __name__ == "__main__": | ||
## Se crea una instancia de la clase Tk, que representa una ventana. | ||
root = Tk() | ||
## Guardamos la ventana en el root. | ||
app = MainWindow(root) | ||
## Lanzamos el bucle principal de la aplicación. | ||
root.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from tkinter import ttk | ||
import tkinter as tk | ||
from cell import Cell | ||
from tkinter import messagebox | ||
from detail_window import detailWindow | ||
|
||
class MainWindow(): | ||
|
||
## En el button_on_clicked se crea la pestaña poniendole el título y el texto que se quiera. | ||
|
||
##def on_button_clicked(self, cell): | ||
## message = "Esto es un/a " + cell.title | ||
## messagebox.showinfo("Frutas", message) | ||
|
||
def __init__(self, root): | ||
## El titulo de la pestaña. | ||
root.title("Frutas") | ||
|
||
## Hacemos una lista de celdas. | ||
self.cells = [ | ||
Cell("Manzana", "C:\\msys64\\home\\Elba\\DI\\sprint1Tkinter\\catalog\\data\\unedited\\manzana_uned.jpg", "Fruta versátil y nutritiva, fuente de vitaminas y fibra, ideal para meriendas y platos saludables."), | ||
Cell("Naranja", "C:\\msys64\\home\\Elba\\DI\\sprint1Tkinter\\catalog\\data\\unedited\\naranja_uned.jpg", "La naranja, fruta cítrica, es jugosa, dulce y llena de vitamina C, perfecta para refrescarse y disfrutar."), | ||
Cell("Plátano", "C:\\msys64\\home\\Elba\\DI\\sprint1Tkinter\\catalog\\data\\unedited\\platano_uned.jpg", "Deliciosa fruta amarilla, fuente de energía y potasio, ideal para un snack saludable."), | ||
Cell("Pera", "C:\\msys64\\home\\Elba\\DI\\sprint1Tkinter\\catalog\\data\\unedited\\pera_uned.jpg", "Fruta jugosa, dulce y rica en fibra, ideal para un bocado fresco y saludable."), | ||
Cell("Arandanos", "C:\\msys64\\home\\Elba\\DI\\sprint1Tkinter\\catalog\\data\\unedited\\arandanos_uned.jpg", "Pequeñas joyas azules, llenas de antioxidantes y sabor fresco, perfectas para postres y desayunos.") | ||
] | ||
|
||
## Recorremos (con el enumerate), almacenando en cada iteración el elemento iterado y su posición. | ||
|
||
for i, cell in enumerate(self.cells): | ||
|
||
## Por cada iteración creamos una etiqueta label con su título e imagen. | ||
label = ttk.Label(root, image = cell.image_tk, text=cell.title, compound = tk.BOTTOM) | ||
## Agregamos la etiqueta a una matriz. | ||
label.grid(row=0, column=i) | ||
## Indicamos que label está pendiente de pulsar el botón izquierdo del ratón sobre la celda. | ||
label.bind("<Button-1>", lambda event, celda = cell: detailWindow(celda)) |