|
|
@ -9,7 +9,6 @@ class Window(Frame):
|
|
|
|
root = Tk()
|
|
|
|
root = Tk()
|
|
|
|
app = Window(root)
|
|
|
|
app = Window(root)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_base():
|
|
|
|
def add_base():
|
|
|
|
out = []
|
|
|
|
out = []
|
|
|
|
for x in baseDropdown['values']:
|
|
|
|
for x in baseDropdown['values']:
|
|
|
@ -24,14 +23,11 @@ def add_base():
|
|
|
|
lbl1 = Label(root, text="\nInvalid base!", font=("Arial", 12))
|
|
|
|
lbl1 = Label(root, text="\nInvalid base!", font=("Arial", 12))
|
|
|
|
lbl1.grid(column=1, row=0)
|
|
|
|
lbl1.grid(column=1, row=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def functionTrigger(a,b,c): # Positional arguments from the trace are not needed for this program, but still must be defined
|
|
|
|
def functionTrigger(a,b,c): # Positional arguments from the trace are not needed for this program, but still must be defined
|
|
|
|
input = numberInput.get()
|
|
|
|
input = numberInput.get()
|
|
|
|
base = int(baseDropdown['values'][baseDropdown.current()]) # Retreive the current selected base
|
|
|
|
base = int(baseDropdown['values'][baseDropdown.current()]) # Retreive the current selected base
|
|
|
|
baseConverter(input, base)
|
|
|
|
baseConverter(input, base)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def baseConverter(userInput, numberBase):
|
|
|
|
def baseConverter(userInput, numberBase):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
decimalNum = int(userInput,numberBase) # First attempt to get the number in decimal.
|
|
|
|
decimalNum = int(userInput,numberBase) # First attempt to get the number in decimal.
|
|
|
@ -56,11 +52,6 @@ def baseConverter(userInput, numberBase):
|
|
|
|
lblOut = Label(root, text=outputText, font=("Arial", 12))
|
|
|
|
lblOut = Label(root, text=outputText, font=("Arial", 12))
|
|
|
|
lblOut.grid(column=0, row=7)
|
|
|
|
lblOut.grid(column=0, row=7)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# set window title
|
|
|
|
|
|
|
|
root.wm_title("Numerical converter")
|
|
|
|
root.wm_title("Numerical converter")
|
|
|
|
|
|
|
|
|
|
|
|
lbl0 = Label(root, text="Add a base:", font=("Arial", 12))
|
|
|
|
lbl0 = Label(root, text="Add a base:", font=("Arial", 12))
|
|
|
@ -69,12 +60,9 @@ lbl0.grid(column=0, row=1)
|
|
|
|
lbl1 = Label(root, text="\n", font=("Arial", 12))
|
|
|
|
lbl1 = Label(root, text="\n", font=("Arial", 12))
|
|
|
|
lbl1.grid(column=1, row=0)
|
|
|
|
lbl1.grid(column=1, row=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addBaseBtn = Button(root, text="Add", command=add_base)
|
|
|
|
addBaseBtn = Button(root, text="Add", command=add_base)
|
|
|
|
addBaseBtn.grid(column=2, row=1)
|
|
|
|
addBaseBtn.grid(column=2, row=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
baseInput = Entry(root,width=10, state='enabled')
|
|
|
|
baseInput = Entry(root,width=10, state='enabled')
|
|
|
|
baseInput.grid(column = 1, row = 1)
|
|
|
|
baseInput.grid(column = 1, row = 1)
|
|
|
|
|
|
|
|
|
|
|
@ -87,7 +75,6 @@ separator1.place(relx=0, rely=0.2, relwidth=1, relheight=1)
|
|
|
|
separator2 = Separator(root, orient='horizontal')
|
|
|
|
separator2 = Separator(root, orient='horizontal')
|
|
|
|
separator2.place(relx=0, rely=0.43, relwidth=1, relheight=1)
|
|
|
|
separator2.place(relx=0, rely=0.43, relwidth=1, relheight=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
baseDropdown = Combobox(root)
|
|
|
|
baseDropdown = Combobox(root)
|
|
|
|
baseDropdown['values']= (2, 10, 16)
|
|
|
|
baseDropdown['values']= (2, 10, 16)
|
|
|
|
baseDropdown.current(1) #set the selected item
|
|
|
|
baseDropdown.current(1) #set the selected item
|
|
|
@ -101,7 +88,6 @@ userInputRaw.trace_add("write", functionTrigger)
|
|
|
|
numberInput = Entry(root,width=10, state='enabled', textvariable=userInputRaw)
|
|
|
|
numberInput = Entry(root,width=10, state='enabled', textvariable=userInputRaw)
|
|
|
|
numberInput.grid(column=1, row = 6)
|
|
|
|
numberInput.grid(column=1, row = 6)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lbl4 = Label(root, text="Number to convert:", font=("Arial", 12))
|
|
|
|
lbl4 = Label(root, text="Number to convert:", font=("Arial", 12))
|
|
|
|
lbl4.grid(column=0, row=6)
|
|
|
|
lbl4.grid(column=0, row=6)
|
|
|
|
|
|
|
|
|
|
|
@ -111,8 +97,6 @@ lbl5.grid(column=50, row=5)
|
|
|
|
lblOut = Label(root, text="rtedgh", font=("Arial", 12))
|
|
|
|
lblOut = Label(root, text="rtedgh", font=("Arial", 12))
|
|
|
|
lblOut.grid(column=0, row=7)
|
|
|
|
lblOut.grid(column=0, row=7)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root.resizable(False, False)
|
|
|
|
root.resizable(False, False)
|
|
|
|
root.geometry('600x400')
|
|
|
|
root.geometry('600x400')
|
|
|
|
root.mainloop()
|
|
|
|
root.mainloop()
|
|
|
|