You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
827 B
Python

from tkinter import *
from tkinter.ttk import *
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
root = Tk()
app = Window(root)
def add_base():
out = []
for x in combo['values']:
out.append(int(x))
out.append(int(txt.get()))
combo['values'] = sorted(out)
# set window title
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)
btn.grid(column=0, row=4)
txt = Entry(root,width=10, state='enabled')
txt.grid(column=0, row = 1)
combo = Combobox(root)
combo['values']= (2, 10, 16)
combo.current(1) #set the selected item
combo.grid(column=0, row=3)
root.geometry('400x300')
root.mainloop()