Tk inter不显示gui窗口中的语句

时间:2015-10-20 13:55:14

标签: python

嗨我将以下定义设置为允许我从输入的数字中计算出一定数量的程序:

def racun() :
number = float(sladkor2.get())
number2 = moka2.get()
number2 = float(number2)
number3 = margarina2.get()
number3 = float(number3)

koliko_tort = (number // sladkor)
koliko_tort2 = (number2 // moka)
koliko_tort3 = (number3 // margarina)

if 1 <= koliko_tort <= koliko_tort2 <= koliko_tort3:
    (print("Kolicina moznih tort je:", int(koliko_tort)))
elif 1 <= koliko_tort3 <= koliko_tort <= koliko_tort2:
    (print("Kolicina moznih tort je:", int(koliko_tort3)))
elif 1 <= koliko_tort2 <= koliko_tort3 <= koliko_tort:
    (print("Kolicina moznih tort je:", int(koliko_tort2)))
elif 1 <= koliko_tort3 <= koliko_tort2 <= koliko_tort :
    (print("Kolicina moznih tort je:", int(koliko_tort3)))
elif 1 <= koliko_tort <= koliko_tort3 <= koliko_tort2:
    (print("Kolicina moznih tort je:", int(koliko_tort)))
elif 1 <= koliko_tort2 <= koliko_tort <= koliko_tort3:
    (print("Kolicina moznih tort je:", int(koliko_tort2)))
else:
    (print("Iz danih kolicin ni mozno narediti nobene torte."))
return

我遇到的问题是输入的变量koliko_tort,koliko_tort2和3的值如果print()没有显示在下面的gui窗口设置中:

mGui = Tk()
sladkor2 = StringVar()
moka2 = StringVar()
margarina2 = StringVar()

mGui.geometry('500x500')

mGui.title('Domaca naloga')
mLabel = Label(text ='Naloga 1', fg= 'brown')
mLabel.pack()

mLabel2 = Label(text = 'Vnesite poljubno kolicino sladkorja v kg:', fg='black').pack()

mEntry = Entry(textvariable = sladkor2).pack()

mLabel3 = Label(text = 'Vnesite poljubno kolicino moke v kg:',     fg='black').pack()

mEntry2 = Entry(textvariable = moka2).pack()

mLabel4 = Label(text = 'Vnesite poljubno kolicino margarine v kg:', fg='black').pack()
mEntry3 = Entry(textvariable = margarina2).pack()

mButton = Button(mGui,text='Naprej', command = racun).pack()
mGui.mainloop()

有什么想法吗?

0 个答案:

没有答案