from tkinter import *
def a():
a=(entry1.get())
s=""
for i in a:
b=a.index(i)
i=int(i)
if i>=4:
bai="1"
if i-4>=2:
shi="1"
ge=str(i-6)
elif i-4<2:
shi="0"
ge=str(i-4)
elif 2<=i<4:
if b==0:
bai=""
shi="1"
ge=str(i-2)
elif b!=0:
bai="0"
shi="1"
ge=str(i-2)
elif i<2:
if b==0:
bai=""
shi=""
ge=str(i)
elif b!=0:
bai="0"
shi="0"
ge=str(i)
c=bai+shi+ge
s=s+c
label1.config(text="{}(八进制)={}(二进制)".format(a,s))
top=Tk()
top.geometry("300x400")
label1=Label(top,text="八进制转二进制")
label1.pack()
entry1=Entry(top,text=0)
entry1.pack()
button1=Button(top,text="转换",command=a)
button1.pack()
top.mainloop()