- List of Experiments
- Week 1
- Week 2
- Week 3
- Week 4
- Week 5
- Week 6
- Week 7
- Week 8
Python GUI Program with Submit and Reset Buttons
Aim:Write a GUI program to create a window wizard having two text labels, two text fields and two buttons as Submit and Reset
Program:
import tkinter as tk
def write_text():
print("Tkinter is easy to create GUI!")
parent = tk.Tk()
frame = tk.Frame(parent)
frame.pack()
text_disp= tk.Button(frame,
text="SUBMIT",
command=write_text
)
text_disp.pack(side=tk.LEFT)
exit_button = tk.Button(frame,
text="RESET",
fg="green",
command=quit)
exit_button.pack(side=tk.RIGHT)
parent.mainloop()
Output:
Sample Viva Questions and Answers
What is a GUI program?
A GUI (Graphical User Interface) program allows users to interact with software through graphical elements like windows, buttons, and text fields instead of text-based commands.What is the purpose of the window wizard in this program?
The window wizard serves as a user-friendly interface for inputting data through text fields and provides options to submit or reset the entered information.What are the main components of the GUI in this program?
The main components include two text labels, two text fields for user input, and two buttons labeled “Submit” and “Reset.”What is the function of the Submit button?
The Submit button is used to process the data entered in the text fields, typically by validating the input and performing an action such as saving or displaying the data.What does the Reset button do?
The Reset button clears the text fields, allowing the user to start over without any previously entered data.How can you create text labels in a GUI?
Text labels can be created using GUI library functions that allow you to define and display static text on the window.What is the significance of text fields in the GUI?
Text fields allow users to input data, making the interface interactive and enabling data collection.Which libraries can be used to create GUI applications in Python?
Common libraries for creating GUI applications in Python include Tkinter, PyQt, and Kivy.How can you handle events in a GUI program?
Events can be handled by defining callback functions that are triggered when users interact with GUI elements, such as clicking buttons.What are some practical applications of GUI programs?
GUI programs are used in various applications, including data entry forms, configuration wizards, and user management systems, enhancing user experience and accessibility.
๐ Python Programming Lab – Complete Guide
Welcome to the Python Programming Lab! This comprehensive lab series is designed to provide a solid foundation in Python programming through practical exercises and hands-on learning. From basic calculations to advanced concepts like file handling, modules, and GUI programming, this lab covers it all. Letโs dive into what youโll be learning throughout this lab course.
๐ Week 1: Introduction to Python Basics
In the first week, you will explore fundamental Python concepts aimed at building a strong foundation for your programming journey.
- Getting Started with Python: Visit the Python Official Website to explore documentation and use the
help()
function in the interpreter. - Python as a Calculator: Learn how to perform basic arithmetic operations like addition, subtraction, multiplication, and division.
- Calculating Compound Interest: Write a program to calculate compound interest using the formula with given principal, rate, and time.
- Distance Calculation: Compute the distance between two points using the distance formula.
- Reading User Details: Write a program to collect and print user details like name, address, email, and phone number.
๐ Week 2: Python Loops and Conditional Statements
This week focuses on using loops and conditional statements effectively.
- Pattern Generation: Print a triangle pattern using nested loops.
- Character Identification: Write a program to identify whether the input is a digit, lowercase, uppercase, or special character.
- Fibonacci Sequence Generation: Use a
while
loop to generate the Fibonacci series. - Prime Numbers Identification: Find all prime numbers within a specified range using the
break
statement.
๐ Week 3: Data Structures and Functions
Dive into data structures and creating functions to enhance your programming skills.
- Converting Lists and Tuples to Arrays: Understand how to convert different data structures.
- Finding Common Values: Compare two arrays to find common values.
- Calculating GCD: Create a function to calculate the greatest common divisor (GCD) of two numbers.
- Palindrome Checker: Write a function that checks if a given string is a palindrome.
๐ Week 4: Advanced Functions and String Manipulation
This week emphasizes sorting, handling duplicate elements, and manipulating strings effectively.
- Checking Sorted Lists: Write a function to check if a list is sorted.
- Handling Duplicates: Create functions to detect and remove duplicates from lists.
- Dictionary Inversion: Write a program to swap keys and values in a dictionary.
- String Manipulation: Add commas between characters, remove words from strings, and convert sentences to title case without using built-in functions.
- Binary String Generation: Use recursion to generate all binary strings of a specified length.
๐ Week 5: Working with Matrices and Modules
Learn to work with matrices and create custom modules for various applications.
- Matrix Operations: Define, print, add, and multiply square matrices using Python.
- Creating Modules: Build modules using geometrical shapes and their operations.
- Exception Handling: Implement exception handling for robust error management.
๐ Week 6: Object-Oriented Programming and Validation
This week focuses on using classes, inheritance, and validation techniques.
- Drawing Shapes with Classes:
- Create classes for rectangles, points, and circles, and draw them on a canvas.
- Add colors and attributes to these shapes to enhance visualization.
- Method Resolution Order (MRO): Demonstrate MRO in multiple inheritance scenarios.
- Data Validation: Write programs to validate phone numbers and email addresses.
๐ Week 7: File Handling and Text Processing
Master file handling techniques and analyzing text data.
- File Merging: Combine the contents of two files into a new file.
- Word Search: Create a function to find specific words in a file.
- Word Frequency Analysis: Identify the most frequent words in a text file.
- Text Statistics: Count words, vowels, blank spaces, lowercase, and uppercase letters in a file.
๐ Week 8: Python Libraries and GUI Programming
Explore advanced Python libraries and build simple graphical user interfaces.
- NumPy, Plotly, and Scipy: Learn how to install and use these powerful libraries for data analysis and visualization.
- Digital Logic Gates: Implement logic gate operations such as AND, OR, NOT, and EX-OR.
- Adder Circuits: Create programs for Half Adders, Full Adders, and Parallel Adders.
- GUI Programming: Build a simple window wizard with text labels, input fields, and buttons using Python’s GUI tools.
๐ Conclusion:
The Python Programming Lab R23 provides you with a strong foundation in Python programming through a wide range of exercises, from basic concepts to advanced topics. By the end of this lab, you will have gained valuable skills in data processing, file handling, OOP, modules, and GUI development. Start coding and enhance your Python skills! ๐