I am just learning Python, and I have a basic concept, and already a few command line programs. Now I'm learning how to create graphical interfaces using Tkinter.
I created a simple graphical interface to accept some user information from the Entry widget, and then when the user clicks the submit button, he should open a dialog.
The dialog should contain the first and last name.
The problem is that I donβt know how to handle the event when the user clicks the submit button.
Here is my code:
from Tkinter import * class GUI(Frame): def __init__(self,master=None): Frame.__init__(self, master) self.grid() self.fnameLabel = Label(master, text="First Name") self.fnameLabel.grid() self.fnameEntry = Entry(master) self.fnameEntry.grid() self.lnameLabel = Label(master, text="Last Name") self.lnameLabel.grid() self.lnameEntry = Entry(master) self.lnameEntry.grid() self.submitButton = Button(self.buttonClick, text="Submit") self.submitButton.grid() def buttonClick(self, event): """ handle button click event and output text from entry area""" pass if __name__ == "__main__": guiFrame = GUI() guiFrame.mainloop()
source share