Tkinter yordamida bir toyifali o'lchovlar uchun konvertor oynasini tashkil etish



Download 234,52 Kb.
Sana17.07.2021
Hajmi234,52 Kb.
#121840
Bog'liq
4-deadline


Tkinter yordamida bir toyifali o'lchovlar uchun konvertor oynasini tashkil etish.

Python GUI (grafik foydalanuvchi interfeysi) ni ishlab chiqish uchun bir nechta variantlarni taklif etadi. Barcha GUI usullaridan tkinter eng ko'p ishlatiladigan usul hisoblanadi. Bu Python bilan ta'minlangan Tk GUI asboblar to'plamiga standart Python interfeysi. Tkinterli Python GUI dasturlarini yaratishning eng tezkor va eng oson usulini chiqaradi. Tkinter yordamida GUI yaratish oson ish.

Tkinter yaratish uchun:

  1. Modulni import qilish - tkinter

  2. Asosiy oynani (konteyner) yarating

  3. Asosiy oynaga istalgan miqdordagi vidjetni qo'shing

  4. Vidjetlarda Trigger tadbirini qo'llang.

Python Tkinter moduli yordamida GUI asosidagi oddiy konvertor yarataylik, u asosiy arifmetik amallarni qo'shish, ayirish, ko'paytirish va bo'lishni bajarishi mumkin.

Quyida amalga oshirish:

from tkinter import *

window = Tk()

window.title("Converter")

window.geometry("500x300+500+350")

measurement1 = ""

measurement2 = ""

def convert_SI(val, unit_in, unit_out):

SI = {'Meter':1, 'Kilometer':1000, 'Centimeter':0.01, 'Millimeter':0.001,

'Micrometer':0.000001, 'Mile':1609.35, 'Yard':0.9144, 'Foot':0.3048,

'Inch':0.0254}

return val*SI[unit_in]/SI[unit_out]

def helpsection():

pass

def selectedInput():

global measurement1

measurement1 = listbox.get(listbox.curselection())

def selectedOutput():

global measurement2

measurement2 = listbox1.get(listbox1.curselection())

def converter():

try:

global measurement1, measurement2

result.set(str(convert_SI(float(inputEntry.get()), measurement1, measurement2)))

except:

result.set("Error")

title = Label(window, text="O'lchov birliklari Converteri", font="Calibri 16")

title.grid(columnspan=3)

result = StringVar()

filemenu = Menu(window)

filemenu.add_command(label='653-18', command=helpsection)

window.config(menu=filemenu)

inputEntry = Entry(window)

inputEntry.grid(row=1, column=0)

arrow = Label(window, text="--->", font="Calibri 20").grid(row=1, column=1)

outputEntry = Entry(window, textvariable=result).grid(row=1, column=2)

convertButton = Button(window, text='O\'tkazish', command=converter).grid(row=2, column=1)

scrollbar = Scrollbar(window)

scrollbar.grid(row=2, column=0, sticky = NE + SE)

listbox = Listbox(window, exportselection=False)

listbox.grid(row=2, column=0)

measurement_list = ['Meter', 'Kilometer', 'Centimeter', 'Millimeter',

'Micrometer', 'Mile', 'Yard', 'Foot', 'Inch']

for measurement in measurement_list:

listbox.insert(END, measurement)

listbox.bind("<>", lambda x: selectedInput())

listbox.config(yscrollcommand=scrollbar.set)

scrollbar.config(command=listbox.yview)

scrollbar1 = Scrollbar(window)

scrollbar1.grid(row=2, column=2, sticky = NE + SE)

listbox1 = Listbox(window, exportselection=False)

listbox1.grid(row=2, column=2)

for measurement in measurement_list:

listbox1.insert(END, measurement)

listbox1.bind("<>", lambda x: selectedOutput())

listbox1.config(yscrollcommand=scrollbar1.set)

scrollbar1.config(command=listbox1.yview)

for i in range(3):

window.grid_rowconfigure(i, weight=1)

window.grid_columnconfigure(i, weight=1)

unit3 = input('')




Download 234,52 Kb.

Do'stlaringiz bilan baham:




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