Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def kg_to_pounds_ounces_grams(kilogram):
- pound = kilogram * 2.20462
- oounce = kilogram * 35.274
- gram = kilogram * 1000
- return [pound, oounce, gram]
- for textWidget,weight in zip(output, kg_to_pounds_ounces_grams(kg) ):
- textWidget.delete(1.0, END)
- textWidget.insert(END,weight)
- from tkinter import *
- window = Tk()
- def kg_to_pounds_ounces_grams(kilogram):
- pound = kilogram * 2.20462
- ounce = kilogram * 35.274
- gram = kilogram * 1000
- return [pound, ounce, gram]
- def convert_button_pressed():
- try:
- kg = float(e1_text.get())
- except:
- kg = float("NaN")
- map(lambda x: x.delete(1.0, END), output)
- # Missing Code goes here!
- l1 = Label(window, text="Kg")
- l1.grid(row=0, column=0)
- e1_text = StringVar()
- e1 = Entry(window, textvariable=e1_text)
- e1.grid(row=0, column=1)
- b1 = Button(window, text="Convert", command=convert_button_pressed)
- b1.grid(row=0, column=2)
- t1 = Text(window, height=1, width=20)
- t1.grid(row=1, column=0)
- t2 = Text(window, height=1, width=20)
- t2.grid(row=1, column=1)
- t3 = Text(window, height=1, width=20)
- t3.grid(row=1, column=2)
- output = [t1, t2, t3]
- window.mainloop()
- [x.delete(1.0, END) for xin output]
- [x.insert(END, w) for x, w in zip(output, kg_to_pound_ounces_grams(kg))]
- [(x.delete(1.0, END), x.insert(END, w)) for x, w in zip(output, kg_to_pound_ounces_grams(kg))]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement