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 tkinter import messagebox as mb
- def saludar():
- print("Hola")
- def elegir_lista():
- posicion = lista.curselection()
- try:
- valor = lista.get(posicion)
- except Exception:
- pass
- else:
- if valor:
- print(valor)
- def elegir_combo():
- try:
- valor = combo.get()
- except Exception:
- pass
- else:
- if valor:
- print(valor)
- ventana = tk.Tk()
- ventana.title("Posicionamiento place")
- ventana.config(width=400, height=800)
- boton = ttk.Button(text="Presione aquí", command=saludar)
- boton.place(x=50, y=10)
- # lista (listbox)
- lista = tk.Listbox()
- lista.insert(0, "Python", "Java", "HTML", "Go")
- lista.place(x=10, y=100)
- boton = ttk.Button(text="Seleccionar", command=elegir_lista)
- boton.place(x=10, y=270)
- # lista desplegable (combobox)
- combo = ttk.Combobox(state='readonly',
- values = ["Ale", "Ana", "Juana", "Victor"],
- )
- combo.place(x=10, y=300)
- boton = ttk.Button(text="Seleccionar", command=elegir_combo)
- boton.place(x=10, y=330)
- # 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.4, relheight=0.40)
- # casilla de verificación
- aceptar = tk.BooleanVar()
- aceptar.set("False")
- casilla = ttk.Checkbutton(text="Aceptar Términos y condiciones", variable=aceptar)
- casilla.place(x=10, y=380)
- # barra de progreso
- barra = ttk.Progressbar(maximum=100)
- barra.step(50)
- barra.start(20)
- barra.place(x=10, y=450, width=200)
- barra = ttk.Progressbar(maximum=100, orient=tk.VERTICAL)
- barra.step(75)
- barra.start(20)
- barra.place(x=300, y=450, height=200)
- # paneles y pestañas
- panel = ttk.Notebook()
- panel.place(x=180, y=50)
- pestania1= ttk.Label(panel,text="Aula virtual")
- pestania2= ttk.Label(panel,text="Buscador de Internet")
- panel.add(pestania1, text="Alumni", padding=20)
- panel.add(pestania2, text="Google", padding=20)
- # cuadros de dialogo
- # retornan True
- mb.showinfo(title="Info",message="Info del sistema")
- mb.showwarning(title="Advertencia",message="Ojo con la info del sistema")
- mb.showerror(title="Error",message="ERROR de sistema")
- # retornan True or False
- mb.askokcancel(title="Advertencia",message="¿desea ejecutar el programa?")
- mb.askyesno(title="Advertencia",message="¿Desea salir del sistema?")
- mb.askretrycancel(title="Advertencia",message="Intente nuevamente")
- ventana.mainloop()
Add Comment
Please, Sign In to add comment