add some stuff idk

master
Costa Aralis 4 years ago
parent aabf617074
commit 1f32849f33

@ -12,27 +12,63 @@ app = Window(root)
def add_base(): def add_base():
out = [] out = []
for x in combo['values']: for x in baseDropdown['values']:
out.append(int(x)) out.append(int(x))
out.append(int(txt.get())) try:
combo['values'] = sorted(out) if out.index(int(baseInput.get())) == 0:
out.append(int(baseInput.get()))
baseDropdown['values'] = sorted(out)
except ValueError:
print("Not a valid base!")
lbl6 = Label(root, text="\nInvalid base!", font=("Arial", 12))
lbl6.grid(column=1, row=0)
# set window title # set window title
root.wm_title("Numerical converter") root.wm_title("Numerical converter")
lbl = Label(root, text="Please enter a number!", font=("Arial Bold", 25))
lbl.grid(column=0, row=0)
btn = Button(root, text="Add", command=add_base) lbl6 = Label(root, text="\n", font=("Arial", 12))
btn.grid(column=0, row=4) lbl6.grid(column=1, row=0)
lbl2 = Label(root, text="Add a base:", font=("Arial", 12))
lbl2.grid(column=0, row=1)
addBaseBtn = Button(root, text="Add", command=add_base)
addBaseBtn.grid(column=2, row=1)
baseInput = Entry(root,width=10, state='enabled')
baseInput.grid(column = 1, row = 1)
lbl5 = Label(root, text="", font=("Arial", 12))
lbl5.grid(column=0, row=3)
separator1 = Separator(root, orient='horizontal')
separator1.place(relx=0, rely=0.2, relwidth=1, relheight=1)
separator2 = Separator(root, orient='horizontal')
separator2.place(relx=0, rely=0.43, relwidth=1, relheight=1)
baseDropdown = Combobox(root)
baseDropdown['values']= (2, 10, 16)
baseDropdown.current(1) #set the selected item
baseDropdown.grid(column=1, row=4)
lbl3 = Label(root, text="\nNumber Base \n of the input:\n", font=("Arial", 12))
lbl3.grid(column=0, row=4)
numberInput = Entry(root,width=10, state='enabled')
numberInput.grid(column=1, row = 6)
txt = Entry(root,width=10, state='enabled') lbl4 = Label(root, text="Number to convert:", font=("Arial", 12))
txt.grid(column=0, row = 1) lbl4.grid(column=0, row=6)
combo = Combobox(root) lbl7 = Label(root, text="", font=("Arial", 12))
combo['values']= (2, 10, 16) lbl7.grid(column=50, row=5)
combo.current(1) #set the selected item
combo.grid(column=0, row=3)
root.geometry('400x300') root.resizable(False, False)
root.geometry('600x400')
root.mainloop() root.mainloop()

Loading…
Cancel
Save