Rus' Handy Converter

mail@pastecode.io avatar
unknown
python
a year ago
2.7 kB
1
Indexable
Never
# PROGRAM
root = Tk()
root.geometry('500x300')

## Choosing a conversion type
conversion_type_frame = Frame(root)
conversion_type_choose_frame = Frame(master=conversion_type_frame)
chosen_conversion_type = StringVar(conversion_type_choose_frame)

### Label
conversion_type_label = Label(master=conversion_type_frame, text='Conversion Types', font='Calibri 18 bold')

### Dropdown
dropdown_options = [
    'Temperature Conversion',
    'Length Conversion',
    'Volume Conversion',
    'Mass Conversion',
    'Area Conversion',
    'Time Conversion'
]

chosen_conversion_type.set('Temperature Conversion')
conversion_type_dropdown = OptionMenu(conversion_type_choose_frame, chosen_conversion_type, *dropdown_options)

### Button
def acquire_value():
    chosen_value = chosen_conversion_type.get()
    print(chosen_value)

conversion_type_choose_button = Button(master=conversion_type_choose_frame, text='Confirm Type', command=acquire_value)

### Unpacking
conversion_type_frame.pack()
conversion_type_label.pack()
conversion_type_dropdown.pack()
conversion_type_choose_frame.pack()
conversion_type_choose_button.pack()


## Choosing the unit of measurement
choose_unit_of_measurement_frame = Frame(master=root)
first_options_frame = Frame(master=choose_unit_of_measurement_frame)
second_options_frame = Frame(master=choose_unit_of_measurement_frame)
from_dropdown_value = StringVar(first_options_frame)
to_dropdown_value = StringVar(second_options_frame)

### Label
choose_unit_of_measurement_label = Label(master=choose_unit_of_measurement_frame, text='Choose which unit of measurement', font='Calibri 14 bold')

### Dropdowns (From-To unit of measurement)
from_dropdown_label = Label(master=first_options_frame, text='From:', font='Calibri 14')
from_dropdown_value.set('Option')

from_dropdown_options = [
    'Option',
    'Option2',
    'Option3',
    'Option4',
    'Option5'
]

from_dropdown = OptionMenu(first_options_frame, from_dropdown_value, *from_dropdown_options)

to_dropdown_label = Label(second_options_frame, text='To:', font='Calibri 14')
to_dropdown_value.set('Option2')

to_dropdown_options = [
    'Option',
    'Option2',
    'Option3',
    'Option4',
    'Option5'
]

to_dropdown = OptionMenu(second_options_frame, to_dropdown_value, *to_dropdown_options)

### Unpacking
choose_unit_of_measurement_frame.pack()
choose_unit_of_measurement_label.pack(pady=20)
first_options_frame.pack()
second_options_frame.pack()
from_dropdown_label.pack(side='left')
from_dropdown.pack(side='left')
to_dropdown_label.pack(side='left')
to_dropdown.pack(side='left')

## Conversion of values (empty for now)

## Run
root.mainloop()