Unit 4: Development of Graphical User Interface (GUI) — Short Questions

12th Class Computer Science · Unit 4: Development of Graphical User Interface (GUI)

SQ1.What is a GUI and why is it important in application development?

A GUI, or Graphical User Interface, is a visual interface that allows users to interact with software using elements like buttons, menus, and forms. It is important because it makes programs easier to understand and operate, especially for non-technical users, by providing visual feedback and reducing the need to remember complex commands. GUI applications are widely used in desktop software, web applications, and mobile apps.

SQ2.What is Tkinter and why is it Python's built-in GUI toolkit?

Tkinter is Python's standard GUI toolkit that comes pre-installed with the language. It provides a set of classes and functions to create windows, buttons, labels, entry fields, and other widgets. It is Python's built-in toolkit because it is easy to learn, lightweight, supports event-driven programming, and is suitable for building small to medium-sized GUI applications quickly and efficiently.

SQ3.How do you create a window and add frames in Tkinter?

A window is created using tk.Tk(), and it can be given a title with window.title() and a size with window.geometry(). Frames are created using tk.Frame(window) and act as containers to divide the window into sections, for example a topframe and a bottomframe. Each frame is then placed in the window using a layout method such as pack(), and widgets are added inside each frame to organize the layout.

SQ4.Name two common widgets used in Tkinter.

Two common widgets used in Tkinter are the Label, which is used to display text or messages on the screen, and the Button, which allows the user to perform an action when it is clicked. (Entry, Menu, and Listbox are other common widgets.)

SQ5.What is the purpose of layout management in Tkinter?

Layout management is used to arrange widgets inside a window in a proper way. It decides the position and size of each widget on the screen. Good layout management makes the interface clear and easy to use, and helps keep the window organized.

SQ6.How does the pack() method organize elements in Tkinter?

The pack() method places widgets in a simple vertical or horizontal order, one after another. It is easy to use and works well for small applications. For example, calling button1.pack(pady=10), button2.pack(pady=10), and button3.pack(pady=10) stacks the three buttons vertically with spacing between them.

SQ7.What is event-driven programming and how is it used in Tkinter?

Event-driven programming is based on actions called events, such as button clicks and key presses. The program remains idle until an event occurs, and when it does, a specific linked function runs to perform a task. In Tkinter this is used by connecting a widget, such as a Button, to a function using the command= option, so the function executes only when the user interacts with the widget.

SQ8.How do you handle user input in Tkinter?

User input is taken through widgets like Entry fields, where the user types text such as a username or password. The value typed can be read in the program using the get() method, for example username = entryuser.get(). A Button widget is usually connected to a function using command= so that when clicked, the function processes the input entered by the user.

SQ9.What is the CRUD operation in database management?

CRUD stands for Create, Read, Update, and Delete and defines the basic actions used to manage data stored in a database. Create adds new records (INSERT), Read retrieves data (SELECT), Update modifies existing records (UPDATE), and Delete removes records (DELETE). Every database-based application depends on these operations to maintain accurate and up-to-date information.

SQ10.How do you connect Python to a database like SQLite?

Python connects to SQLite using the built-in sqlite3 module. First, import sqlite3 and call sqlite3.connect("school.db") to open (or create) the database file, then create a cursor object with connection.cursor() to execute SQL queries. Queries are run using cursor.execute(), changes are saved with connection.commit(), and the connection is closed with connection.close() once operations are complete.