Advertisement
teslariu

widgets

Apr 26th, 2022
1,209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.82 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # place.py
  5. import tkinter as tk
  6. from tkinter import ttk
  7. from tkinter import messagebox
  8.  
  9. def saludar():
  10.     print("Hola")
  11.    
  12.    
  13. def seleccion_lista():
  14.     nombre = lista.get(lista.curselection())
  15.     print(nombre)
  16.    
  17. def seleccion_combo():
  18.     curso = combo.get()
  19.     print(curso)
  20.    
  21.    
  22.  
  23. ventana = tk.Tk()
  24. ventana.title("Posicionamiento place")
  25. ventana.config(width=400, height=800)
  26.  
  27. boton = ttk.Button(text="Saludo", command=saludar)
  28. boton.place(x=50,y=10)
  29.  
  30. label = ttk.Label(text="Apreta el botón y te saludo...")
  31. label.place(x=160,y=10)
  32.  
  33. # lista
  34. lista = tk.Listbox()
  35. lista.insert(0,"Alejandro","Juana","Ana")
  36. lista.place(x=10,y=100)
  37. boton = ttk.Button(text="Seleccionar", command=seleccion_lista)
  38. boton.place(x=10,y=270)
  39.  
  40. # lista desplegable
  41. combo = ttk.Combobox(state="readonly",values=["C","Python","Java","GO"])
  42. combo.place(x=10,y=300)
  43. boton = ttk.Button(text="Seleccionar", command=seleccion_combo)
  44. boton.place(x=10,y=330)
  45.  
  46.  
  47. # imagen dentro de una etiqueta
  48. imagen = tk.PhotoImage(file="camion.png")
  49. label = ttk.Label(image=imagen)
  50. label.place(relx=0.5, rely=0.5, relwidth=0.5, relheight=0.5)
  51.  
  52. #casilla de verificacion
  53. estado = tk.BooleanVar()
  54. estado.set("True")
  55. casilla = ttk.Checkbutton(text="Acepto los términos y condiciones", variable=estado)
  56. casilla.place(x=10,y=380)
  57.  
  58. # barra de progreso
  59. barra = ttk.Progressbar(maximum=100)
  60. barra.place(x=10, y=450, width=200)
  61. barra.step(50)
  62. barra.start(10)
  63.  
  64. barra = ttk.Progressbar(maximum=100, orient=tk.VERTICAL)
  65. barra.place(x=300, y=500, height=200)
  66. barra.step(50)
  67. barra.start(10)
  68.  
  69.  
  70. ### cuadros de dialogo
  71.  
  72. messagebox.showinfo(title="INFO", message="Hola gente")
  73. messagebox.showwarning(title="ADVERTENCIA", message="Ojito")
  74. messagebox.showerror(title="JAJAJA", message="Te equivocaste")
  75.  
  76.  
  77.  
  78. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement