การใช้งาน Python GUI (Tkinter) : การ Combobox

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การใช้งาน Python GUI (Tkinter) : การ Combobox

การใช้งาน Python GUI (Tkinter) : การ Combobox

โดย Jom07 » 28/02/2018 6:36 pm

การใช้งาน Python GUI (Tkinter) : การ Combobox เป็นการสร้างหน้าต่างที่กำหนดตัวเลือกโดยเฉพาะ เช่น

ตัวอย่าง

โค้ด: เลือกทั้งหมด

from tkinter import *
from tkinter import ttk

def obtener():
    if int(combo.get()) >15:
        texto.set("Edad: " + combo.get() + ". E")
    else:
        texto.set("Edad: " + combo.get() + ". E")

ventana = Tk()
texto = StringVar()
texto.set("Edad : ")
combo = ttk.Combobox(ventana)
combo.place(x=50,y=100)
combo['values'] = ('15', '16', '17' ,'18','19','20')
combo.current(3)
boto = Button(ventana,command=obtener,text="Calcular").place(x=100,y=150)
etiqueta = Label(ventana,textvariable=texto).place(x=40,y=200)
ventana.geometry("300x300")
ventana.mainloop()
ผลรัน
รูปภาพ

ข้างบน