Introduction

In this blog, I am going to create a textbox and text capturing function in Python GUI application. When a user enters the text in the textbox and clicks the Submit button, the button action will capture the text and display the Hi text in Python console.
Software requirement
Python 3.5 and IDLE (Python 3.5)
Programming code
  1. import tkinter as tk
  2. from tkinter import ttk
  3. win = tk.Tk()# Application Name
  4. win.title("Python GUI App")# Label
  5. lbl = ttk.Label(win, text = "Enter the name:").grid(column = 0, row = 0)# Click event
  6. def click():
  7. print("Hi," + name.get())# Textbox widget
  8. name = tk.StringVar()
  9. nameEntered = ttk.Entry(win, width = 12, textvariable = name).grid(column = 0, row = 1)# Button widget
  10. button = ttk.Button(win, text = "submit", command = click).grid(column = 1, row = 1)
  11. win.mainloop()
About the code
The Python GUI application will appear on the screen.
Output