from tkinter import *
import re
def c10to2(x):
    if re.match(r'\d+\b',x):
        s = ''
        x = int(x)
        while x >=1:
            s+=str(x%2)
            x//=2
        return s[::-1]
    else:
        return 'ERROR'
def c2to10(x):
    if re.match(r'[01]+\b',x):
        x = str(x)
        y = 0
        n = len(x)-1
        for i in x:
            y+=int(i)*(2**n)
            n-=1
        return y
    return 'ERROR'
def etake(e):
    number = my_number.get()
    x = my_sys.get()
    y = target_sys.get()
    if x == '10' and y == '2':
        my_solve.delete(0,END)
        my_solve.insert(END,c10to2(number))
    elif x == '2' and y == '10':
        my_solve.delete(0,END)
        my_solve.insert(END,c2to10(number))
    else:
        return 'ERROR'

w = Tk()
w.title('Системы счисления')
w.geometry('280x145')
w.resizable(0,0)
first_text = Label(w,text='Перевести из ',font=14)
second_text = Label(w,text='в',font=14)
my_sys = Entry(w,width=3)
target_sys = Entry(w,width=3)
my_number=Entry(w,width=16)
my_solve=Entry(w,width=16)
b = Button(w,text='Go!',bg='pink',height=2,width=5,command=lambda event='<Button-1>': etake('<Button-1>')) # Теперь результат выдаётся как по нажатию на кнопку "Go", так и...
my_number.bind('<Return>',etake) # ... по простому нажатию на Enter

first_text.place(x=6,y=10)
my_sys.place(x=115,y=10)
second_text.place(x=140,y=10)
target_sys.place(x=165,y=10)
my_number.place(x=6, y=70)
b.place(x=115,y=65)
my_solve.place(x=170,y=70)

w.mainloop()