Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # posicionamiento place
- def seleccion_listbox():
- opcion = lista.get(lista.curselection())
- print(opcion)
- def seleccion_combo():
- opcion = combo.get()
- print(opcion)
- import tkinter as tk
- from tkinter import ttk
- from tkinter import messagebox
- ventana = tk.Tk()
- ventana.title("Posicionamiento place")
- ventana.config(width=400, height=800, bg="gray")
- # imagen dentro de una etiqueta
- imagen_camion = tk.PhotoImage(file="camion.png")
- label = ttk.Label(image=imagen_camion)
- label.place(relx=0.5, rely=0.5, relwidth=0.50, relheight=0.50)
- # lista fija (listbox)
- lista = tk.Listbox()
- lista.insert(0,"Python","Erlang","Java","GO")
- lista.place(x=10, y=50)
- boton = ttk.Button(text="Seleccionar", command=seleccion_listbox)
- boton.place(x=10, y=220)
- # lista desplegable (combobox)
- combo = ttk.Combobox(state="readonly", values=[0,1,2,3,4,5,6,7,8,9,10])
- combo.place(x=10, y=250)
- boton = ttk.Button(text="Seleccionar", command=seleccion_combo)
- boton.place(x=10, y=280)
- # casilla de verificacion
- seleccion = tk.BooleanVar()
- seleccion.set("False")
- casilla = ttk.Checkbutton(text="Acepto términos y condiciones", variable=seleccion)
- casilla.place(x=10, y=330)
- # barra de progreso
- barra = ttk.Progressbar(maximum=100)
- barra.place(x=10, y=400, width=200)
- barra.step(20)
- barra = ttk.Progressbar(orient=tk.VERTICAL, maximum=100)
- barra.place(x=300, y=400, height=200)
- barra.step(50)
- barra.start(5) # por defecto aumenta cada 50 miliseg
- ####### pestañas ####################
- panel = ttk.Notebook()
- panel.place(x=20, y=500)
- pestaña_alumni = ttk.Label(panel,text="El aula virtual está en alumni.education")
- pestaña_google = ttk.Label(panel,text="El buscador a usar es google.com.ar")
- panel.add(pestaña_alumni, text="Alumni", padding=20)
- panel.add(pestaña_google, text="Buscador", padding=20)
- ########## cuadros de dialogo #######################
- # siempre retornan OK
- r = messagebox.showinfo(title="INFO", message="Ultima clase")
- print(r)
- r = messagebox.showwarning(title="OJO", message="Estudien para los exámenes")
- print(r)
- r = messagebox.showerror(title="ERROR", message="2 x 8 no es 15")
- print(r)
- # retornan True of False
- opcion = messagebox.askokcancel(title="Pregunta", message="¿Quiere salir")
- print(opcion)
- opcion = messagebox.askyesno(title="Edad", message="¿Es mayor de 18 años?")
- print(opcion)
- opcion = messagebox.askretrycancel(title="Pregunta", message="¿Desea intentarlo nuevamente")
- print(opcion)
- ventana.mainloop()
Add Comment
Please, Sign In to add comment