Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import tkinter as tk
- from tkinter import ttk
- def saludar():
- nombre = caja_nombre.get()
- print(f"Hola {nombre}")
- def imprimir_lista():
- seleccion = lista.get(lista.curselection())
- print(seleccion)
- def imprimir_combo():
- seleccion = combo.get()
- print(seleccion)
- ventana = tk.Tk()
- ventana.title("Posicionamiento place")
- ventana.config(width=400, height=800)
- # evito que alguien cambie el tamaño de la ventana
- # ventana.resizable(0,0)
- boton = ttk.Button(text="Saludar", command=saludar)
- boton.place(x=50, y=10, width=100, height=40)
- caja_nombre = ttk.Entry()
- caja_nombre.place(x=200, y=10)
- caja_nombre.insert(0, "Ej: Juan Perez")
- etiqueta = ttk.Label(text="Ingrese su nombre")
- etiqueta.place(x=210, y=40)
- # imagen dentro de una etiqueta
- imagen = tk.PhotoImage(file='camion.png')
- label = ttk.Label(image=imagen)
- label.place(relx=0.5, rely=0.5, relwidth=0.5, relheight=0.5)
- # lista (listbox)
- lista = tk.Listbox()
- lista.insert(0,"Python","Java","C++","Go")
- lista.place(x=10, y=100)
- boton = ttk.Button(text="Guardar selección", command=imprimir_lista)
- boton.place(x=10, y=250)
- # lista desplegable (combobox)
- combo = ttk.Combobox(state="readonly",
- values=[
- "Visual Basic",
- "Erlang",
- "R",
- "JavaScript"
- ]
- )
- combo.place(x=10, y=300)
- boton = ttk.Button(text="Guardar selección", command=imprimir_combo)
- boton.place(x=10, y=330)
- # casilla de verificacion
- estado = tk.BooleanVar()
- estado.set("True")
- casilla = ttk.Checkbutton(text="Aceptar las condiciones", variable=estado)
- casilla.place(x=10, y=380)
- # barra de progreso
- barra = ttk.Progressbar(maximum=100, orient=tk.VERTICAL)
- barra.place(x=10, y=450, height=200)
- barra.step(30)
- barra.start(10)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement