0% found this document useful (0 votes)
18 views2 pages

Exp 10 Python

This document is a Python script that creates a simple GUI application using Tkinter. The application includes labels, entry fields, radio buttons for options, and buttons to display user input and selected options. It sets up a main window titled 'Welcome to ACPCE' with specified dimensions and functionalities for user interaction.

Uploaded by

dattarajnadkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Exp 10 Python

This document is a Python script that creates a simple GUI application using Tkinter. The application includes labels, entry fields, radio buttons for options, and buttons to display user input and selected options. It sets up a main window titled 'Welcome to ACPCE' with specified dimensions and functionalities for user interaction.

Uploaded by

dattarajnadkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

import tkinter as tk

# Create the main window


root = tk.Tk()
# Set window title and dimensions
root.title("Welcome to ACPCE")
root.geometry('400x300')
# Font for the radio buttons
_font = ('Arial', 14)
# Adding a label to the root window for the entry input
lbl = tk.Label(root, text="Are you a Student?")
lbl.grid(row=0, column=0, padx=10, pady=10)
lbl1 = tk.Label(root, text="Username?")
lbl1.grid(row=1, column=1, padx=1, pady=1)
# Adding Entry field
txt = tk.Entry(root, width=20)
txt.grid(row=0, column=1, padx=10, pady=10)
# Function to display user input when the button is clicked
def clicked():
res = "You wrote: " + txt.get() # Add space for better readability
lbl.configure(text=res)
# Adding a button that calls the 'clicked' function when pressed
btn = tk.Button(root, text="ENTER", fg="red", command=clicked)
btn.grid(row=1, column=0, columnspan=3, pady=10)
# Create radio buttons for selecting options
selected_choice = tk.StringVar()
radio_button1 = tk.Radiobutton(root, text="Option 1", variable=selected_choice,
value="Option 1", font=_font)
radio_button2 = tk.Radiobutton(root, text="Option 2", variable=selected_choice,
value="Option 2", font=_font)
radio_button3 = tk.Radiobutton(root, text="Option 3", variable=selected_choice,
value="Option 3", font=_font)
radio_button1.grid(row=2, column=0, padx=10, pady=5)
radio_button2.grid(row=2, column=1, padx=10, pady=5)
radio_button3.grid(row=2, column=2, padx=10, pady=5)
# Add a button to display the selected radio button choice
def show_choice():
choice_label.config(text=f"Selected: {selected_choice.get()}")
# Add a button that updates the label with the selected option
choice_btn = tk.Button(root, text="Show Selected Option", command=show_choice,
font=_font)
choice_btn.grid(row=3, column=0, columnspan=3, pady=10)
# Label to display the selected option
choice_label = tk.Label(root, text="Selected: None", font=_font)
choice_label.grid(row=4, column=0, columnspan=3, pady=10)
# Run the Tkinter event loop
root.mainloop()

You might also like