How to make a Unit Converter GUI | Python | Volume, Length | By The Art of Programming| #1|

preview_player
Показать описание
Hi Guys !!!
I have created a Unit Converter using tkinter module in python. This program converts 2 value - Volume, Length.

Link to The background music

Hope you like it!!
Рекомендации по теме
Комментарии
Автор

Here's Thee code:
# Importing the modules
import tkinter as tk
from tkinter.constants import UNITS
import tkinter.font as font
from functools import partial
from tkinter import StringVar, messagebox
from tkinter import ttk

# Creating the window
window =tk.Tk()
window.geometry('500x600')
window.title('Unit Converter')
window.configure(bg = 'peach puff2')

# Creating the fonts
font1 = font.Font(family = 'helvetica', size = '30')
font2 = font.Font(family = 'helvetica', size = '10')
font3 = font.Font(family = 'helvetica', size = '20')

# All the functions
# Selected function
def selected():
pass

# Fromfunc function
def fromfunc():
pass

# Tofunc function
def tofunc():
pass

# Creating the unit converter label
main = tk.Label(window, text = 'Unit Converter', bg = 'peach puff2', fg = 'blue')
main['font'] = font1
main.place(relx = '0.48', rely = '0.1', anchor = 'center')

# Creating the unit label
unit = tk.Label(window, text = 'Unit -:', bg = 'peach puff2')
unit['font'] = font2
unit.place(relx = '0.25', rely = '0.28')

# Creating the main combobox
n = StringVar()
unitdd = ttk.Combobox(window, width = '35', textvariable = n)

# Values
unitdd['values'] = ('Volume',
'Length',
'Mass')

unitdd.place(relx = '0.57', rely = '0.3', anchor = 'center')
unitdd.current()
unitdd.bind('<<ComboboxSelected>>', selected)

# Creating the from label
label_from = tk.Label(window, text = 'From -:', bg = 'peach puff2')
label_from['font'] = font2
label_from.place(relx = '0.238', rely = '0.37')

# Creating the fromdd
f = StringVar()
fromdd = ttk.Combobox(window, width = '35', textvariable = f)

fromdd.place(relx = '0.57', rely = '0.39', anchor = 'center')
fromdd.current()
fromdd.bind('<<ConboboxSelected>>', fromfunc)

# Creating the to label
to = tk.Label(window, text = 'To -:', bg = 'peach puff2')
to['font'] = font2
to.place(relx = '0.268', rely = '0.45')

# Creating the to drop down
t = StringVar()
todd = ttk.Combobox(window, width = 35, textvariable = t)

todd.place(relx = '0.57', rely = '0.47', anchor = 'center')
todd.current()
todd.bind('<<ConboboxSelected>>', tofunc)

# Creting the result label
result = tk.Label(window, text = '', bg= 'white', width = 20)
result['font'] = font3
result.place(relx = '0.21', rely = '0.6')

# Creating the art label
art = tk.Label(window, text = 'The Art Of Programming', bg= 'peach puff2', fg = 'blue')
art['font'] = font3
art.place(relx = '0.21', rely = '0.9')


# Creating the mainloop
window.mainloop()

theartofprogramming
welcome to shbcf.ru