141
11. Radio tugmachasining qiymatini olish
Tanlangan radio tugmani yoki uning qiymatini
olish uchun parametrni
o'zgaruvchiga o'tkazib, uning qiymatini olish mumkin.
from tkinter import *
from tkinter.ttk Radiobutton *
def tanlash():
label.configure(text=selected.get())
window =Tk()
window.title(“Mening birinchi grafik oyman”)
window.geometry(‘350x150’)
selected=IntVar()
radio1=Radiobutton(window, text= ‘Birinchi’, value=1, variable=selected)
radio2=Radiobutton(window, text= ‘Ikkinchi’, value=2, variable=selected)
radio3=Radiobutton(window, text= ‘Uchinchi’, value=3, variable=selected)
button=Button(window, text= “Natija”, command=tanlash)
label=Label(window)
radio1.grid(column=0, row=0)
radio2.grid(column=1, row=0)
radio3.grid(column=2, row=0)
button.grid(column=3, row=0)
label.grid(column=0, row=1)
window.mainloop()
142
Har safar radio tugmachasini tanlaganingizda, o'zgaruvchining qiymati tugma
qiymatiga o'zgartiriladi.
Dostları ilə paylaş: