为什么没有输出(没有错误)?

时间:2018-01-06 20:06:37

标签: python python-3.x button tkinter ttk

我正在制作一个GUI来比较用户输入的两个变量,但是当我输入数字并按下按钮时没有任何事情发生(没有输出)

listOfNum.stream().map(integer -> integer.toString()).collect(Collectors.toList());

1 个答案:

答案 0 :(得分:0)

节目结束了谢谢。

from tkinter import *
from tkinter import ttk


root = Tk(className = "biggerOrLess")

ttk.Label(root, text="Compare two numbers").grid(row=0)

txt = StringVar()

def updatelabel(result):
        txt.set(result)

Lab = ttk.Label(root, textvariable=txt).grid(row=3)

def biggerOrLess(x,y):
        try:
                x = UIP.get()
                y = UIP2.get()
                x = float(x)
                y = float(y)


                if x == y :
                    result = (x, " = " ,y)
                elif x > y :
                    result = (x," > ",y)
                elif x < y :
                    result = (x," < ",y)


                updatelabel(result)
        except:
                updatelabel('wrong input')

UIP = Entry(root,)
UIP2 = Entry(root,)

UIP.grid(row=2)
UIP2.grid(row=4)


B1 = Button(root, text = 'Compare', command = lambda :biggerOrLess(UIP, UIP2))
B1.grid(row=3, column=2)

root.mainloop()