Raxmonberdiyev soibjonning


B3 = Button(top, text ="info", relief=RAISED, bitmap="info")



Download 0,89 Mb.
bet11/13
Sana06.07.2022
Hajmi0,89 Mb.
#747933
1   ...   5   6   7   8   9   10   11   12   13
Bog'liq
ASD

B3 = Button(top, text ="info", relief=RAISED, bitmap="info")
B4 = Button(top, text ="question", relief=RAISED, bitmap="question")
B5 = Button(top, text ="warning", relief=RAISED, bitmap="warning")
B1.pack()
B 2.pack()
B3.pack()
B4.pack()
B5.pack()
top.mainloop()
2.2-rasm:

2.6.TKINTER CURSORS (“KURSORLAR”)



Python Tkinter turli xil sichqoncha kursorlarini qo'llab-quvvatlaydi. To'liq grafik sizning operatsion tizimingizga qarab farq qilishi mumkin.
Bu erda qiziqarli bo'lganlar ro'yxati :

"circle" - aylana

"clock" - soat

"dotbox" – nuqta

"exchange" - almashish

"heart" – yurak

"man" - kishi

"pirate" – qaroqchi

"plus" - plyus

"sizing" – O`lcham

"spider" – O`rgimchak

"star" – yulduz

"target" - nishon

"trek" - trek

"watch" - tomosha

Misol
Kursorni turli tugmachalarda harakatlantirish orqali quyidagi misolni sinab ko'ring !
(2.5-rasm)
from tkinter import *
t
op = Tk()

B1 = Button(top, text ="circle", relief=RAISED, cursor="circle")
B2 = Button(top, text ="plus", relief=RAISED, cursor="plus")
B1.pack()
B2.pack()
top.mainloop()
2.5-rasm:

  1. KALKULYATOR DASTURI


Bu bobda biz kalkulyator dasturini yaratishni o’rganib chiqamiz.Bunda birinchi bo’lib tkinter kutubxonasini chaqirib olamiz. Keyin bir necha funksiyalar va kodlardan foydalanib oyna yaratib olamiz.Cal.tile funksiyasidan foydalangan holda dasturimizga “calculator”dep yozib olamiz.(3.1-rasm)

3.1-rasm.Kalkulator dasturining dastlabki ko’rinishi .
Entru vidjetidan foydalanib fon rangi, o’lchamini yozamiz.Tugmalarni qo’yib “padx” va “pady”lardan foydalanib ular orasidagi olchamlarni(oraliqlarni) kiritamiz.Button vidjtidan tugmalarga raqam va amallarni yozishda foydalanamiz. Call.mainlop() bilan dasturni tugatamiz.(3.2-rasm)

3.2-rasm.Kalkulyator dasturi ko’rinishi (davomi)
Natijada bizning dasturimiz kalkulyator oynasini chiqaradi(3.3-rasm).Bu dasturimizda biz ko’paytirish , bo’lish ,ayirish , qo’shish amallarini bemalol bajara olamiz.Dasturni yaratishda tkinter vidjetlaridan va ko’plab funksiya,kodlardan foydalandik .

3.3-rasm.Kalkulator dasturining oxirgi ko’rinishi.
from tkinter import *
from tkinter.font import *
oyna=Tk()
oyna.title("Kalkulyator")
oyna.geometry("500x500")
oyna.configure(bg="dodger blue")
myfont=Font(size=15)
n=Entry(oyna, width=25, font=myfont)
n.grid(row=0, column=0)
n.place(x=25, y=25)
k=0
l=0
s=""
def a1():
return n.insert(END,"1")
def a2():
return n.insert(END,"2")
def a3():
return n.insert(END,"3")
def a4():
return n.insert(END,"4")
def a5():
return n.insert(END,"5")
def a6():
return n.insert(END,"6")
def a7():
return n.insert(END,"7")
def a8():
return n.insert(END,"8")
def a9():
return n.insert(END,"9")
def a0():
return n.insert(END,"0")
def tp():
global a,b
b=int(n.get())
n.delete(0,END)
a="+"
return
def tm():
global a,b
b=int(n.get())
n.delete(0,END)
a="-"
return
def tk():
global a,b
b=int(n.get())
n.delete(0,END)
a="*"
return
def tb():
global a,b
b=int(n.get())
n.delete(0,END)
a="/"
return
def tc():
return n.delete(0,END)
def tn():
global a,b,c
if a=="+":
c=int(n.get())
n.delete(0,END)
n.insert(END,str(b+c))
if a=="-":
c=int(n.get())
n.delete(0,END)
n.insert(END,str(b-c))
if a=="*":
c=int(n.get())
n.delete(0,END)
n.insert(END,str(b*c))
if a=="/":
c=int(n.get())
n.delete(0,END)
n.insert(END,str(b/c))
return
Button(oyna, text="1", width=4, font=myfont, bg="yellow", command=a1).place(x=20, y=80)
Button(oyna, text="2", width=4, font=myfont, bg="yellow", command=a2).place(x=80, y=80)
Button(oyna, text="3", width=4, font=myfont, bg="yellow", command=a3).place(x=140, y=80)
Button(oyna, text="4", width=4, font=myfont, bg="yellow", command=a4).place(x=200, y=80)
Button(oyna, text="5", width=4, font=myfont, bg="yellow", command=a5).place(x=20, y=130)
Button(oyna, text="6", width=4, font=myfont, bg="yellow", command=a6).place(x=80, y=130)
Button(oyna, text="7", width=4, font=myfont, bg="yellow", command=a7).place(x=140, y=130)
Button(oyna, text="8", width=4, font=myfont, bg="yellow", command=a8).place(x=200, y=130)
Button(oyna, text="9", width=4, font=myfont, bg="yellow", command=a9).place(x=20, y=180)
Button(oyna, text="0", width=4, font=myfont, bg="yellow", command=a0).place(x=80, y=180)
Button(oyna, text="+", width=4, font=myfont, bg="green", command=tp).place(x=140, y=180)
Button(oyna, text="-", width=4, font=myfont, bg="green", command=tm).place(x=200, y=180)
Button(oyna, text="*", width=4, font=myfont, bg="green", command=tk).place(x=20, y=230)
Button(oyna, text="/", width=4, font=myfont, bg="green", command=tb).place(x=80, y=230)
Button(oyna, text="C", width=4, font=myfont, bg="white", command=tc).place(x=140, y=230)
Button(oyna, text="=", width=4, font=myfont, bg="pink", command=tn).place(x=200, y=230)
oyna.mainloop()

Download 0,89 Mb.

Do'stlaringiz bilan baham:
1   ...   5   6   7   8   9   10   11   12   13




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish