0
我是Tkinter的新手,我只是想爲我的多重性計算器製作一個GUI。當我告訴它打印多樣性時,它給了我一個看似隨機的數字串。任何幫助?Tkinter不會正確顯示變量
import sys
import tkinter
from tkinter import *
def Start():
numberOneList = []
numberTwoList = []
multiples = 10000
iterations = 0
multiplicity = int(entry3.get())
numberOne = int(entry1.get())
numberTwo = int(entry2.get())
for i in range(multiples):
mNumberOne = numberOne * i
numberOneList.append(mNumberOne)
mNumberTwo = numberTwo * i
numberTwoList.append(mNumberTwo)
text1.insert(INSERT, "\n")
text1.insert(INSERT, "Common multiplicities:")
text1.insert(INSERT, "\n")
text1.insert(INSERT, "Calculating...")
text1.insert(INSERT, "\n")
for i in numberOneList:
for a in numberTwoList:
if a == i:
if a != 0:
text1.insert(INSERT, int(entry1.get()), "x", i/int(entry1.get()), "=", i)
text1.insert(INSERT, int(entry2.get()), "x", a/int(entry2.get()), "=", a)
text1.insert(INSERT, "\n")
iterations += 1
if iterations == multiplicity:
sys.exit()
else:
continue
else:
continue
else:
continue
master = tkinter.Tk()
master.title("Multiplicity Calculator")
text1 = Text(master)
text1.pack(side = BOTTOM)
label1 = Label(master, text = "Number 1: ")
label1.pack(side = LEFT)
entry1 = Entry(master, bd = 5, textvariable = IntVar())
entry1.pack(side = LEFT)
label2 = Label(master, text = "Number 2: ")
label2.pack(side = LEFT)
entry2 = Entry(master, bd = 5, textvariable = IntVar())
entry2.pack(side = LEFT)
label3 = Label(master, text = "Number of Multiplicities")
label3.pack(side = LEFT)
entry3 = Entry(master, bd = 5, textvariable = IntVar())
entry3.pack(side = LEFT)
button1 = Button(master, text = "Calculate", width = 8, command = Start)
button1.pack()
master.mainloop()
的問題是線
text1.insert(INSERT, int(entry1.get()), "x", i/int(entry1.get()), "=", i)
text1.insert(INSERT, int(entry2.get()), "x", a/int(entry2.get()), "=", a)
感謝您的幫助!