我正在编写一个python gui,它对2个十六进制输入进行计算,然后将计算输出到文本框。这是我得到的错误我尝试使用(int(Text.get))放入(int)但是它将无法工作仍然得到相同的错误。我正在使用python 2.7.13。
File "C:\Users\oaeel\Desktop\guialg.py", line 5, in calculate
Seed = (a1 << 8 | a2)
TypeError: unsupported operand type(s) for <<: 'str' and 'int'
from Tkinter import *
def calculate():
Seed = (a1 << 8 | a2)
num1 = Seed
num2 = Seed >> 8 & 255
num3 = Seed & 255
num4 = e2.insert
num5 = e6.insert
print(num4)
print(num5)
root = Tk()
root.geometry("218x200")
b1 = Button(text="calculate seed", command=calculate)
b1.grid(row=2, column=2, pady=10)
f1 = LabelFrame(text="Seed")
f1.configure(width=1, height=1)
f1.grid(row=0, column=2, padx=10)
f2 = LabelFrame(text="Key")
f2.configure(width=1, height=1)
f2.grid(row=1, column=2, padx=10)
e1 = Entry(f1, width=2)
e1.grid(row=0, column=1, padx=10, pady=10)
e2 = Text(f2, width=2, height=1)
e2.grid(row=0, column=1, padx=10, pady=10)
e5 = Entry(f1, width=2)
e5.grid(row=0, column=2, padx=10, pady=10)
e6 = Text(f2, width=2, height=1)
e6.grid(row=0, column=2, padx=10, pady=10)
a1 = (e1.get())
a2 = (e5.get())
root.mainloop()