2017年10月1日 星期日

Tkinter Text Entry / Text Show



from tkinter import *
from tkinter.messagebox import *

def show_answer():
    Ans = int(num1.get()) + int(num2.get())
    blank.insert(0, Ans)


main = Tk()
Label(main, text = "Enter Num 1:").grid(row=0, column=1)
Label(main, text = "Enter Num 2:").grid(row=1, column=1)
Label(main, text = "The Sum is:").grid(row=2, column=1)


num1 = Entry(main)
num2 = Entry(main)
blank = Entry(main)


num1.grid(row=0, column=2)
num2.grid(row=1, column=2)
blank.grid(row=2, column=2)


Button(main, text='Quit', command=main.quit).grid(row=4, column=1, sticky=W, pady=4)
Button(main, text='Show', command=show_answer).grid(row=4, column=2, sticky=W, pady=4)

mainloop()

沒有留言:

張貼留言

WOKWI LED + MQTT Node-Red SQLite

WOKWI LED + MQTT Node-Red SQLite const char *mqtt_broker = "broker.mqtt-dashboard.com" ; const char *topic1 = "alex9ufo/e...