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
- from pprint import pprint
- def seleccion_listbox():
- curso = lista.get(lista.curselection())
- print(f"Curso elegido: {curso}")
- def seleccion_combo():
- nombre = combobox.get()
- print(f"Nombre elegido: {nombre}")
- ventana = tk.Tk()
- ventana.title("Formulario")
- ventana.config(width=400, height=800)
- # si quiero que la ventana no se pueda modificar el tamaño
- # ventana.resizable(0,0)
- # lista fija (listbox)
- lista = tk.Listbox()
- lista.insert(0,"Python", "Java", "C++", "Erlang","Ruby", "GO")
- lista.place(x=10,y=20)
- boton = ttk.Button(text="Seleccione una opcion", command=seleccion_listbox)
- boton.place(x=10, y=200)
- # lista desplegable (combobox)
- combobox = ttk.Combobox(
- state="readonly",
- values=["Ana","Pedro","Oscar","Ines"],
- )
- combobox.place(x=10, y=300)
- boton = ttk.Button(text="Seleccione un nombre", command=seleccion_combo)
- boton.place(x=10, y=330)
- # imagen dentro de una etiqueta
- imagen = tk.PhotoImage(file="camion.png")
- etiqueta = ttk.Label(image = imagen)
- etiqueta.place(relx=0.5, rely=0.5, relwidth=0.5, relheight=0.5)
- # casilla de verificacion
- estado = tk.BooleanVar()
- estado.set("True")
- casilla = ttk.Checkbutton(text="Acepto las condiciones", variable=estado)
- casilla.place(x=10, y=400)
- # barra de progreso
- barra = ttk.Progressbar(maximum=100)
- barra.place(x=10, y=450, width=200)
- barra.step(10)
- barra.start(50)
- barra = ttk.Progressbar(orient=tk.VERTICAL)
- barra.place(x=300, y=450, height=200)
- barra.start(50)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement