×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

PyGTK MCQs (Multiple-Choice Questions)

PyGTK is a Python binding for the GTK+ graphical user interface toolkit. It provides Python developers with access to GTK+ widgets, containers, dialogs, menus, signals, and other components for creating desktop graphical applications.

PyGTK MCQs

This section contains PyGTK Multiple-Choice Questions with Answers. These PyGTK MCQs cover important concepts such as widgets, windows, containers, signals, callbacks, buttons, text controls, menus, dialogs, layouts, and the GTK main loop. Practice these MCQs to test and improve your knowledge of PyGTK.

List of PyGTK MCQs

The following are the popular MCQs on PyGTK:

1. What is PyGTK primarily used for?

  1. Developing web servers
  2. Creating graphical user interfaces
  3. Managing databases
  4. Processing audio files

Answer: B) Creating graphical user interfaces

Explanation:

PyGTK provides Python bindings for the GTK+ toolkit and is used to create desktop graphical user interfaces. It provides widgets and other components required for building GUI applications.

2. Which module is commonly imported when developing an application with PyGTK?

  1. pygui
  2. gtk
  3. pygtkui
  4. gtkpython

Answer: B) gtk

Explanation:

The gtk module provides the higher-level GTK+ widgets used by PyGTK applications.

import gtk

3. Which statement was commonly used to request PyGTK 2.x compatibility?

  1. pygtk.version('2.0')
  2. pygtk.require('2.0')
  3. gtk.require('2.0')
  4. gtk.version('2.0')

Answer: B) pygtk.require('2.0')

Explanation:

In PyGTK 2.x applications, pygtk.require('2.0') was commonly used to request the PyGTK 2.0 API before importing the gtk module.

import pygtk
pygtk.require('2.0')
import gtk

4. Which class represents a top-level window in PyGTK?

  1. gtk.Window
  2. gtk.TopWindow
  3. gtk.MainWindow
  4. gtk.FrameWindow

Answer: A) gtk.Window

Explanation:

gtk.Window represents a top-level window in PyGTK. It can contain child widgets and provides the main window for many GUI applications.

5. Which function starts the GTK main event loop?

  1. gtk.start()
  2. gtk.run()
  3. gtk.main()
  4. gtk.event_loop()

Answer: C) gtk.main()

Explanation:

The gtk.main() function starts the GTK main loop. The main loop processes events generated by user interactions and other sources.

gtk.main()

6. Which function is used to terminate the current GTK main loop?

  1. gtk.stop()
  2. gtk.main_quit()
  3. gtk.exit()
  4. gtk.quit_loop()

Answer: B) gtk.main_quit()

Explanation:

The gtk.main_quit() function terminates the current level of the GTK main loop.

gtk.main_quit()

7. Which method is used to make a PyGTK widget visible?

  1. display()
  2. show()
  3. visible()
  4. open()

Answer: B) show()

Explanation:

The show() method makes a widget visible. It is commonly used when constructing a PyGTK interface.

8. Which method recursively displays a widget and its child widgets?

  1. show_children()
  2. show_all()
  3. display_all()
  4. show_widgets()

Answer: B) show_all()

Explanation:

The show_all() method recursively shows a widget and its child widgets. It is particularly useful after adding several child widgets to a container.

window.show_all()

9. Which method is used to hide a PyGTK widget?

  1. hide()
  2. remove()
  3. close()
  4. invisible()

Answer: A) hide()

Explanation:

The hide() method hides a widget without necessarily destroying it.

10. Which class is used to create a push button in PyGTK?

  1. gtk.PushButton
  2. gtk.Button
  3. gtk.ClickButton
  4. gtk.CommandButton

Answer: B) gtk.Button

Explanation:

The gtk.Button class creates a standard push button. A button can contain a label or another widget and can emit a signal when activated.

11. Which signal is commonly associated with clicking a gtk.Button?

  1. pressed
  2. clicked
  3. selected
  4. activated_button

Answer: B) clicked

Explanation:

The clicked signal is emitted when a gtk.Button is activated by the user.

12. Which method is used to connect a signal to a callback function?

  1. connect()
  2. attach()
  3. bind_signal()
  4. register()

Answer: A) connect()

Explanation:

The connect() method is used to associate a GTK signal with a callback function.

button.connect("clicked", callback)

13. What is a callback function in PyGTK?

  1. A function executed in response to an event or signal
  2. A function that creates a Python package
  3. A function used only for drawing images
  4. A function that starts the operating system

Answer: A) A function executed in response to an event or signal

Explanation:

A callback is a function that is invoked when a connected signal or event occurs. For example, a button's clicked signal can call a callback function.

14. Which class is commonly used to display a text label in PyGTK?

  1. gtk.TextLabel
  2. gtk.Label
  3. gtk.StaticText
  4. gtk.Caption

Answer: B) gtk.Label

Explanation:

The gtk.Label widget displays text in a PyGTK application.

15. Which class provides a single-line text entry control in PyGTK?

  1. gtk.TextBox
  2. gtk.Entry
  3. gtk.Input
  4. gtk.Edit

Answer: B) gtk.Entry

Explanation:

The gtk.Entry widget provides a single-line text entry field.

16. Which method retrieves the text currently contained in a gtk.Entry?

  1. get_text()
  2. read_text()
  3. get_value()
  4. read_value()

Answer: A) get_text()

Explanation:

The get_text() method returns the text currently contained in a gtk.Entry widget.

17. Which method sets the text of a gtk.Entry?

  1. set_value()
  2. set_text()
  3. write_text()
  4. put_text()

Answer: B) set_text()

Explanation:

The set_text() method changes the text displayed in a gtk.Entry.

entry.set_text("Hello")

18. Which widget is suitable for entering multiple lines of text?

  1. gtk.Entry
  2. gtk.TextView
  3. gtk.TextField
  4. gtk.MultiEntry

Answer: B) gtk.TextView

Explanation:

gtk.TextView is designed for displaying and editing multi-line text. It normally works with a gtk.TextBuffer that stores the text.

19. Which object stores the text displayed or edited by a gtk.TextView?

  1. gtk.TextStore
  2. gtk.TextBuffer
  3. gtk.TextData
  4. gtk.TextModel

Answer: B) gtk.TextBuffer

Explanation:

A gtk.TextBuffer stores the text and related information used by a gtk.TextView.

20. Which class is the base class for PyGTK widgets?

  1. gtk.Control
  2. gtk.Widget
  3. gtk.GUIObject
  4. gtk.Component

Answer: B) gtk.Widget

Explanation:

gtk.Widget is the base class for GTK widgets. Many commonly used interface controls inherit directly or indirectly from this class.

21. Which container is used to arrange child widgets horizontally or vertically?

  1. gtk.Box
  2. gtk.GridBox
  3. gtk.LayoutBox
  4. gtk.PanelBox

Answer: A) gtk.Box

Explanation:

gtk.Box is a container used to arrange child widgets in a single row or column depending on its orientation.

22. Which class is commonly used for a horizontal box in PyGTK?

  1. gtk.HBox
  2. gtk.HorizontalBox
  3. gtk.HContainer
  4. gtk.RowBox

Answer: A) gtk.HBox

Explanation:

gtk.HBox is the PyGTK 2.x container traditionally used to arrange child widgets horizontally.

23. Which class is used to arrange child widgets vertically in PyGTK?

  1. gtk.VBox
  2. gtk.VerticalBox
  3. gtk.VContainer
  4. gtk.ColumnBox

Answer: A) gtk.VBox

Explanation:

gtk.VBox is traditionally used in PyGTK 2.x to arrange child widgets vertically.

24. Which method adds a widget to a container?

  1. add()
  2. insert_widget()
  3. attach_widget()
  4. append_widget()

Answer: A) add()

Explanation:

The add() method is used by container widgets to add a child widget. For example, a window can contain a single child widget using add().

window.add(button)

25. Which method is commonly used to add a child widget to a gtk.Box?

  1. pack_start()
  2. add_child()
  3. insert_start()
  4. append_widget()

Answer: A) pack_start()

Explanation:

The pack_start() method is used to add a child to the beginning of a box container. Its parameters can control properties such as expansion and padding.

26. Which method adds a child widget to the end of a gtk.Box?

  1. pack_end()
  2. add_end()
  3. append_end()
  4. insert_end()

Answer: A) pack_end()

Explanation:

The pack_end() method adds a child widget at the end of a box container.

27. Which container arranges widgets in rows and columns?

  1. gtk.Table
  2. gtk.RowColumn
  3. gtk.GridContainer
  4. gtk.Matrix

Answer: A) gtk.Table

Explanation:

In PyGTK 2.x, gtk.Table is a container that arranges child widgets in a table-like structure consisting of rows and columns.

28. Which method is used to attach a widget to a gtk.Table?

  1. attach()
  2. add_at()
  3. place()
  4. insert_table()

Answer: A) attach()

Explanation:

The attach() method is used to place a child widget within specified rows and columns of a gtk.Table.

29. Which widget provides a list of selectable choices in PyGTK?

  1. gtk.Choice
  2. gtk.ComboBox
  3. gtk.SelectBox
  4. gtk.OptionList

Answer: B) gtk.ComboBox

Explanation:

gtk.ComboBox provides a control that allows the user to select an item from a list of choices.

30. Which widget provides a tabbed interface in PyGTK?

  1. gtk.TabView
  2. gtk.Notebook
  3. gtk.TabControl
  4. gtk.PageTabs

Answer: B) gtk.Notebook

Explanation:

gtk.Notebook is a tabbed container that allows multiple child pages to be displayed with tabs.

31. Which widget is used to create a menu bar in PyGTK?

  1. gtk.MenuBar
  2. gtk.MenuPanel
  3. gtk.MainMenu
  4. gtk.MenuContainer

Answer: A) gtk.MenuBar

Explanation:

The gtk.MenuBar widget displays menu items horizontally and is commonly placed at the top of an application window.

32. Which widget represents an individual menu in PyGTK?

  1. gtk.Menu
  2. gtk.MenuList
  3. gtk.SubMenu
  4. gtk.MenuBox

Answer: A) gtk.Menu

Explanation:

The gtk.Menu widget represents a menu that can contain menu items and submenus.

33. Which widget represents an item inside a PyGTK menu?

  1. gtk.MenuOption
  2. gtk.MenuItem
  3. gtk.ItemMenu
  4. gtk.MenuEntry

Answer: B) gtk.MenuItem

Explanation:

gtk.MenuItem represents an individual item in a menu. It can contain a label and can be associated with a callback.

34. Which widget is used to display a message dialog in PyGTK?

  1. gtk.MessageDialog
  2. gtk.MessageBox
  3. gtk.AlertDialog
  4. gtk.DialogMessage

Answer: A) gtk.MessageDialog

Explanation:

gtk.MessageDialog provides a convenient dialog for displaying messages and standard response buttons.

35. Which class is used to create a general-purpose dialog in PyGTK?

  1. gtk.Dialog
  2. gtk.PopupDialog
  3. gtk.GeneralDialog
  4. gtk.WindowDialog

Answer: A) gtk.Dialog

Explanation:

gtk.Dialog provides a general-purpose dialog window that can contain widgets and buttons for interacting with the user.

36. Which dialog is used to allow the user to select a file?

  1. gtk.FileDialog
  2. gtk.FileChooserDialog
  3. gtk.SelectFile
  4. gtk.FileWindow

Answer: B) gtk.FileChooserDialog

Explanation:

gtk.FileChooserDialog provides a dialog for selecting files or folders, depending on its configured action.

37. Which widget can be used to select a color in PyGTK?

  1. gtk.ColorChooser
  2. gtk.ColorButton
  3. gtk.ColorSelector
  4. gtk.ColorWidget

Answer: B) gtk.ColorButton

Explanation:

gtk.ColorButton is a button that allows the user to select a color through a color selection interface.

38. Which widget allows the user to select a date from a calendar?

  1. gtk.DatePicker
  2. gtk.Calendar
  3. gtk.DateChooser
  4. gtk.DaySelector

Answer: B) gtk.Calendar

Explanation:

gtk.Calendar is a widget that displays a calendar and allows the user to select a date.

39. Which widget is used to represent a selectable on/off option?

  1. gtk.CheckButton
  2. gtk.CheckBox
  3. gtk.ToggleCheck
  4. gtk.OptionButton

Answer: A) gtk.CheckButton

Explanation:

gtk.CheckButton provides a check button that can be selected or cleared by the user.

40. Which widget is used when the user should choose one option from a group of radio buttons?

  1. gtk.RadioButton
  2. gtk.OptionGroup
  3. gtk.SingleChoice
  4. gtk.RadioChoice

Answer: A) gtk.RadioButton

Explanation:

gtk.RadioButton creates a radio button. Radio buttons can be grouped so that one option can be selected from a set of related choices.

41. Which module provides lower-level window-system functionality in PyGTK?

  1. gtk.lowlevel
  2. gtk.gdk
  3. gtk.system
  4. gtk.windowapi

Answer: B) gtk.gdk

Explanation:

The gtk.gdk module provides lower-level functionality associated with the underlying windowing system. It contains objects and functions used below the higher-level GTK widget layer.

42. Which module provides text layout and rendering functionality in PyGTK?

  1. textgtk
  2. pango
  3. gtk.font
  4. gtk.textlayout

Answer: B) pango

Explanation:

The pango module provides access to the Pango text layout and rendering functionality used by GTK applications.

43. Which module in PyGTK provides accessibility-related functionality?

  1. access
  2. atk
  3. gtk.access
  4. pango.access

Answer: B) atk

Explanation:

The atk module provides access to the Accessibility Toolkit functionality used to support accessibility in GTK applications.

44. Which module was used in PyGTK to load interfaces from XML descriptions using libglade?

  1. gtk.xml
  2. gtk.glade
  3. gtk.builder
  4. gtk.ui

Answer: B) gtk.glade

Explanation:

The gtk.glade module provided access to libglade functionality for loading graphical user interfaces described in XML.

45. Which PyGTK class is used to build an interface from an XML UI definition?

  1. gtk.Builder
  2. gtk.XMLLoader
  3. gtk.InterfaceBuilder
  4. gtk.UIBuilder

Answer: A) gtk.Builder

Explanation:

gtk.Builder can construct an interface from an XML UI definition. It is a newer approach compared with the older libglade-based mechanism.

46. Which widget is used to display a horizontal or vertical separator?

  1. gtk.Separator
  2. gtk.SeparatorMenuItem
  3. gtk.Divider
  4. gtk.Line

Answer: A) gtk.Separator

Explanation:

gtk.Separator is the base class for separator widgets. PyGTK also provides specific horizontal and vertical separator widgets.

47. Which method can be used to set the title of a gtk.Window?

  1. set_caption()
  2. set_title()
  3. set_name()
  4. set_header()

Answer: B) set_title()

Explanation:

The set_title() method sets the title displayed by a gtk.Window.

window.set_title("My Application")

48. Which method can be used to set the default size of a PyGTK window?

  1. set_size()
  2. set_default_size()
  3. set_window_size()
  4. set_initial_size()

Answer: B) set_default_size()

Explanation:

The set_default_size() method sets the default width and height of a window.

window.set_default_size(400, 300)

49. Which signal is commonly connected to gtk.main_quit() to close an application window?

  1. delete-event
  2. close-window
  3. exit-event
  4. window-close

Answer: A) delete-event

Explanation:

The delete-event signal is commonly connected to a callback that calls gtk.main_quit(), allowing the application to terminate its main loop when the window is closed.

window.connect("delete-event", gtk.main_quit)

50. Which statement correctly creates a simple PyGTK button?

  1. button = gtk.PushButton("Hello")
  2. button = gtk.Button("Hello")
  3. button = gtk.Button.create("Hello")
  4. button = gtk.WidgetButton("Hello")

Answer: B) button = gtk.Button("Hello")

Explanation:

The gtk.Button constructor can receive a label as an argument. The following statement creates a button displaying the text "Hello".

button = gtk.Button("Hello")
Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2026 www.includehelp.com. All rights reserved.