Python provides various options for developing graphical user interfaces (GUIs). Tkinter, wxPython and JPython is wellknow.
Tkinter comes in build with Python package and it provide most of the GUI component like canvas, button, checkbox, radiobutton, button etc.
In below example we are using Eclipse IDE along with python plugin to develop gui
Code:-
from tkinter import *
import tkinter
from tkinter import messagebox
from lib2to3.fixer_util import Number
import tkinter
from tkinter import messagebox
from lib2to3.fixer_util import Number
top = tkinter.Tk()
L1 = Label(top, text="First Number")
L1.pack( side = LEFT)
E1 = Entry(top, bd =5)
L1.pack( side = LEFT)
E1 = Entry(top, bd =5)
E1.pack(side = LEFT)
L2 = Label(top, text="Second Number")
L2.pack( side = LEFT)
E2 = Entry(top, bd =5)
E2.pack(side = LEFT)
def helloCallBack():
print("E1.get()"+E1.get())
print("E2.get()"+E2.get())
a = int(E1.get())
b = int(E2.get())
answer = a + b
#messagebox.showinfo( "Hello Python", "Hello World")
print("answer"+str(answer))
E3.insert(0, answer)
print("E1.get()"+E1.get())
print("E2.get()"+E2.get())
a = int(E1.get())
b = int(E2.get())
answer = a + b
#messagebox.showinfo( "Hello Python", "Hello World")
print("answer"+str(answer))
E3.insert(0, answer)
B = tkinter.Button(text ="Add", command = helloCallBack)
B.pack(side = LEFT)
L3 = Label(top, text="Answer")
L3.pack( side = LEFT)
E3 = Entry(top, bd =5)
L3.pack( side = LEFT)
E3 = Entry(top, bd =5)
E3.pack(side = LEFT)
top.mainloop()
top.mainloop()
No comments:
Post a Comment