133
from tkinter import *
window =Tk()
window.title(“Mening birinchi grafik oyman”)
label1=Label(window, text= “Salom dasturchi”, font=(“Times New Roman”, 30))
label1.grid(column=0, row=0)
window.geometry(‘350x150’)
button1=Button(window, text= “Natija”, font=(“Times New Roman”, 18)
button1.grid(column=1, row=0)
window.mainloop()
5. Matn rangini va tugma fonini o'zgartirish
Siz Button yoki boshqa vidjet matnining rangini fg xususiyatidan foydalanib
o'zgartirishingiz mumkin.
Bundan
tashqari, bg xususiyati yordamida istalgan
vidjetning fon rangini
o'zgartirishingiz mumkin.
button1 = Button(window, text="Natija", bg="yellow", fg="blue")
from tkinter import *
window =Tk()
window.title(“Mening birinchi grafik oyman”)
label1=Label(window, text= “Salom dasturchi”, font=(“Times New Roman”, 30))
label1.grid(column=0, row=0)
134
window.geometry(‘350x150’)
button1=Button(window, text="Natija", bg="yellow", fg="blue", font=(“Times New
Roman”, 18)
button1.grid(column=1, row=0)
window.mainloop()
Agar siz tugmani bosmoqchi bo'lsangiz, hech narsa bo'lmaydi, chunki tugmani
bosish hodisasi hali yozilmagan.
Tugmani bosing
Birinchidan, biz tugma bosilganda bajarilishi kerak bo'lgan
funksiyani
yozamiz:
from tkinter import *
def tugma()
label1.configure(text= “Iltimos tegmang …”)
window =Tk()
window.title(“Mening birinchi grafik oyman”)
label1=Label(window, text= “Salom dasturchi”, font=(“Times New Roman”, 30))
label1.grid(column=0, row=0)
window.geometry(‘350x150’)
button1=Button(window, text="Natija", command=tugma)
button1.grid(column=1, row=0)