simple Python GUI program using Tkinter with a button and a textbox

Here’s a simple Python GUI program using Tkinter with a button and a textbox:

import tkinter as tk

def on_button_click():
    text = textbox.get()
    print("Button clicked!")
    print("Text entered:", text)

# Create the main window
root = tk.Tk()
root.title("Simple GUI")

# Create a textbox
textbox = tk.Entry(root, width=30)
textbox.pack(pady=10)

# Create a button
button = tk.Button(root, text="Click me", command=on_button_click)
button.pack()

# Run the GUI
root.mainloop()

This program creates a window with a textbox and a button. When the button is clicked, it prints the text entered in the textbox to the console. You can extend this program by adding more widgets or functionality as needed.

Leave a Reply

Your email address will not be published. Required fields are marked *