0% found this document useful (0 votes)
7 views5 pages

abhishek006

The document outlines a laboratory experiment for a Python programming course focused on implementing a GUI using Tkinter. It details the aim, prerequisites, expected outcomes, and provides a theoretical background on Tkinter, including various widgets and geometry management methods. The conclusion emphasizes the successful creation of a GUI with multiple interactive elements.

Uploaded by

exxo.711
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)
7 views5 pages

abhishek006

The document outlines a laboratory experiment for a Python programming course focused on implementing a GUI using Tkinter. It details the aim, prerequisites, expected outcomes, and provides a theoretical background on Tkinter, including various widgets and geometry management methods. The conclusion emphasizes the successful creation of a GUI with multiple interactive elements.

Uploaded by

exxo.711
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/ 5

Sub: Skill Base Lab: Python Programming Course code: CSL405

Semester: IV Course: AI&DS


Laboratory no: 101 Name of subject teacher: Rajesh Khotre

Name of the Student:Abhishek


Abhishek Mishra
Manak Kumar Roll no: VU2F2324006
VU2F2324014

Experiment No.05

A.1 Aim:

To implement GUI with python containing widgets such as labels, textbox, radio, checkboxes
and custom dialog boxes. A.2 Prerequisite:

1. C,JAVA Language A.3

Outcome:

After successful completion of this experiment students will be able to

To demonstrate basic concepts in python

A.4 Theory & Procedure:


What is Tkinter?

Tkinter is the standard GUI library for Python, allowing developers to create graphical user
interfaces for their applications quickly and easily. It is built on the Tk GUI toolkit and
provides an object-oriented interface to work with the components of this toolkit.

When Python is combined with Tkinter, it provides a fast and easy way to create desktop
applications. Tkinter abstracts the complexities of dealing with graphical elements, making it
easier for developers to design and interact with the GUI of their applications.

Creating a Simple Tkinter Application

Creating a GUI application using Tkinter follows a few simple steps. Here’s a general
outline:

1. Import the Tkinter module


The first step in creating a Tkinter application is to import the Tkinter library:
import tkinter

2. Create the main window


The main window serves as the root window of your application, where all the
widgets (buttons, text fields, etc.) will reside.
3. Add widgets
Tkinter provides a variety of widgets that can be added to your application. Some
common widgets include buttons, labels, text boxes, etc.
4. Enter the main event loop
Finally, enter the main event loop using the mainloop() method. This ensures
that the application remains open and responsive to user input. top.mainloop()

This creates a window that is essentially empty, awaiting the addition of widgets.

Widgets in Tkinter are the building blocks of your GUI application. They allow you to create
interactive elements for users to interact with. Below are descriptions of the various Tkinter
widgets:

1. Button
The Button widget creates a clickable button.
2. Canvas
The Canvas widget is used for drawing shapes like lines, ovals, and rectangles.
3. Checkbutton
The Checkbutton widget allows the user to select one or more options, typically
displayed as checkboxes.
4. Entry
The Entry widget creates a text box where users can enter a single line of text.
5. Frame
A Frame widget acts as a container for other widgets, useful for organizing your
layout.
6. Label
The Label widget is used to display text or images.
7. Listbox
The Listbox widget creates a list of options for the user to choose from.
8. Menubutton
The Menubutton widget creates a button that displays a menu when clicked.
9. Menu
The Menu widget contains a list of commands that can be added to a Menubutton.
10. Message
The Message widget displays multiline text for the user.
11. Radiobutton
A Radiobutton widget displays a set of options, where only one can be
selected at a time.
12. Scale
The Scale widget is a slider that lets the user select a value within a given range.
13. Scrollbar
The Scrollbar widget is used to add scrolling functionality to other widgets like
Listbox or Text.
14. Text
The Text widget allows the user to enter multiple lines of text.
15. Toplevel
The Toplevel widget creates a separate window that can be used for additional
content.
16. Spinbox
A Spinbox widget is a type of Entry widget that lets the user select from a
fixed list of values.

Standard Widget Attributes

Widgets in Tkinter come with several standard attributes that control their appearance and
behavior. Some of these attributes include:

• Dimensions: You can set the height and width of widgets (e.g., width, height).
• Colors: Widgets can have background and foreground colors (e.g., bg, fg).
• Fonts: The font of text in widgets can be customized using attributes like font.
• Anchors: You can align text or other elements inside a widget using anchor points like n, s, e,
w (north, south, east, west).
• Relief Styles: These control the border appearance (e.g., flat, raised, sunken, groove).
• Bitmaps: Widgets can display bitmaps, which are small images.
• Cursors: The appearance of the mouse cursor can be customized (e.g., arrow, hand2).

Geometry Management

Tkinter provides three main geometry managers for organizing widgets inside a container:

1. pack() Method
This method organizes widgets in blocks and places them in the parent container. You
can control the side of the window (e.g., top, left, right).
button = tkinter.Button(top, text="Click Me")
button.pack(side="top")
2. grid() Method
The grid() method arranges widgets in a table-like structure. You specify the row
and column for each widget.
3. place() Method
The place() method allows for absolute positioning of widgets, where you specify
the x and y coordinates.
These geometry managers help ensure that your application’s interface is well-organized
organized and
visually appealing. By choosing the right manager, you can fine
fine-tune
tune your layout to meet
specific design requirements.

Program:
Conclusion: Thus we Creating GUI with python containing widgets such as labels, textbox,
radio, checkboxes and custom dialog boxes

R1 R2 R3
TOTAL
DOP DOS ATTENDENCE CONDUCTION VIVA 10 SIGNATURE
MARKS
2 MARKS 4 MARKS 4 MARKS

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy