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 imprimir_saludo():
- print("Boton presionado")
- def guardar_nombre():
- nom = nombre.get()
- print(nom)
- def guardar_listbox():
- seleccion = lista.get(lista.curselection())
- print(seleccion)
- def guardar_combobox():
- seleccion = combobox.get()
- print(seleccion)
- ###################################################################
- ventana = tk.Tk()
- ventana.title("Posicionamiento place")
- ventana.config(width=400, height=800)
- # botones
- boton = ttk.Button(text="Hola mundo", command=imprimir_saludo)
- boton.place(x=50, y=10, width=100, height=50)
- # etiquetas
- label = ttk.Label(text="Hola mundo")
- label.place(x=160, y=120)
- # imagen (adentro 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)
- # caja de texto
- nombre = ttk.Entry()
- nombre.place(x=10, y=70)
- boton = ttk.Button(command=guardar_nombre)
- boton.place(x=150, y=70, width=100, height=50)
- boton.config(text="Guardar nombre")
- # lista estática (listbox)
- lista = tk.Listbox()
- lista.insert(0,"Python", "C", "C++", "Java")
- lista.place(x=10, y=100)
- boton = ttk.Button(text="Guardar selección", command=guardar_listbox)
- boton.place(x=10, y=270)
- # lista desplegable (combobox)
- combobox = ttk.Combobox(state="readonly",
- values=[
- "Visual Basic",
- "Python",
- "Erlang",
- "Rust",
- "Prolog"
- ]
- )
- combobox.place(x=10, y=300)
- boton = ttk.Button(text="Imprimir selección", command=guardar_combobox)
- boton.place(x=10, y=330)
- # casilla de verificacion
- estado = tk.BooleanVar()
- estado.set("True")
- checkbutton = ttk.Checkbutton(text="Aceptar las condiciones",variable=estado)
- checkbutton.place(x=10, y=380)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment