1. Write a Python program to display Entry box(Text Box) and Button on the GUI window and print Hello on command window when press "Submit" Button
from Tkinter import *
win =Tk()
win.title('Printing Hello on Command Window')
win.geometry('350x250') # Fixing size of GUI window
mylabel = Label(win, text="Name") # To display Label
mylabel.grid(row=0, column=0) # To fix position of Label
myentry = Entry(win) # To display Entry Box
myentry.grid(row=0, column=1)
def helloCallback(): # Function to display Hello
print ("Hello")
mybutton = Button(win, text="Submit", command=helloCallback) # To display Button
mybutton.grid(row=0, column=2)
win.mainloop()
2. Write a Python program to display Entry box(Text Box) and Button on the GUI window and accept name of student in entry box (e.g. Vihaan) and print "Hello Vihaan" on command window when press "Submit" Button
from Tkinter import *
win = Tk()
win.geometry('350x200')
def helloCallback():
word=myentry.get()
print("Hello "+word)
mylabel = Label(win, text="Name")
mylabel.grid(row=0, column=0)
myentry = Entry(win, bd=5)
myentry.grid(row=0, column=1)
mybutton = Button(win, text="Submit",command=helloCallback)
mybutton.grid(row=0, column=2)
win.mainloop()