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

Python Exp5

Uploaded by

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

Python Exp5

Uploaded by

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

Experiment : 05

Title : Creating GUI with python containing widgets such as labels,


textbox, radio, checkboxes and custom dialog boxes.

Program:
import tkinter as tk
from tkinter import messagebox

Aim : Create a new window


root = tk.Tk()

Aim : Set the title of the window


root.title("My GUI")

Aim : Create a label widget


label = tk.Label(root, text="Welcome to my GUI!")
label.pack()

Aim : Create a textbox widget


textbox = tk.Entry(root)
textbox.pack()

Aim : Create a radio button widget


radio = tk.Radiobutton(root, text="Option 1",
value=1) radio.pack()
radio2 = tk.Radiobutton(root, text="Option 2",
value=2) radio2.pack()

Aim : Create a checkbox widget


checkbox = tk.Checkbutton(root, text="Check me!")
checkbox.pack()

Aim : Create a custom dialog box


def showDialog():
messagebox.showinfo("Message", "Hello World!")
button = tk.Button(root, text="Click me",
command=showDialog)
button.pack()

Aim : Start the main loop of the window


root.mainloop()

Output:

Conclusion: We have written basic program to create a basic GUI

You might also like