程序代写代做代考 python gui Starting Out with Python 4e (Gaddis)

Starting Out with Python 4e (Gaddis)
Chapter 13 GUI Programming

TRUE/FALSE

1. Python does not have GUI programming features built into the language itself.

ANS: T

2. Programs that use tkinter do not always run reliably in IDLE.

ANS: T

3. A root widget’s destroy method can be used as a callback function for a Quit button.

ANS: T

4. Radio buttons can be used to allow the user to make multiple selections at one time.

ANS: F

5. Checkbutton widgets are displayed in groups and used to make mutually exclusive selections.

ANS: F

6. In a GUI environment, no text input is possible.

ANS: F

7. The pack method determines where a widget should be positioned.

ANS: T

8. An info dialog box is a window that displays a message to the user and has an OK button which, when clicked, closes the dialog box.

ANS: T

9. To use an Entry widget to get data entered by a user, you must use the Entry widget’s set method.

ANS: F

10. The Entry widget’s get method retrieves either numeric or string data.

ANS: F

11. To use the showinfo function, the tkinter.messagebox module must be imported.

ANS: T

12. The point (0,0) represents the same place in a window with the Canvas widget as with turtle graphics.

ANS: F

MULTIPLE CHOICE

1. What are the items that appear on the graphical interface window called?
a.
buttons

b.
icons

c.
widgets

d.
graphical elements

ANS: C

2. A __________ program is an event-driven program.
a.
GUI

b.
command line

c.
procedural

d.
modular

ANS: A

3. Which widget allows the user to select a value by moving a slider along a track?
a.
Scrollbar

b.
Toplevel

c.
Scale

d.
Slider

ANS: C

4. Which widget will display multiple lines of text?
a.
Label

b.
Canvas

c.
Message

d.
Text

ANS: C

5. Which widget creates an area that displays one line of text or an image?
a.
Label

b.
Canvas

c.
Message

d.
Text

ANS: A

6. Which widget allows the user to enter a single line of input from the keyboard?
a.
Toplevel

b.
Entry

c.
Message

d.
Text

ANS: B

7. In an event-driven program, the __________ accepts the user’s commands.
a.
register

b.
CPU

c.
operating system

d.
GUI

ANS: C

8. In an event-driven environment, the user interacts with
a.
the graphical unit

b.
the user interface

c.
the register

d.
the CPU

ANS: B

9. The acronym GUI stands for
a.
Graphical User’s Interface

b.
Graphical User Interface

c.
Graphical User Interaction

d.
Graphical Union Interface

ANS: B

10. In Python, what module is used to create a GUI program?
a.
tkinter

b.
pygui

c.
python_gui

d.
pycanvas

ANS: A

11. In a GUI environment most interactions are done through small windows known as __________ that display information and allow the user to perform actions.
a.
input boxes

b.
windows

c.
dialog boxes

d.
message boxes

ANS: C

12. In a(n) __________ interface, a prompt is displayed that allows the user to enter a command which is then executed.
a.
windows

b.
command line

c.
GUI

d.
operating

ANS: B

13. In a(n) __________ interface, the user can determine the order in which things happen.
a.
windows

b.
command line

c.
GUI

d.
operating

ANS: C

14. Which of the following is not a method of the Canvas widget?
a.
create_line

b.
create_oval

c.
create_button

d.
create_text

ANS: C

15. A __________ is a container that can be used to organize the widgets in a window.
a.
Textbox

b.
Label

c.
Frame

d.
Canvas

ANS: C

16. Which of the following must you include with your program so you can display a message to the user with the showinfo function?
a.
import tkinter

b.
import canvas
import messagebox

c.
import messagebox

d.
import tkinter
import tkinter.messagebox

ANS: D

17. Given the following code, which line defines the size of the window?
import tkinter
class myShape:
def __init__(self):
self.main_window = tkinter.Tk()
self.canvas = tkinter.Canvas(self.main_window,
width=200, height=200)
self.canvas.create_rectangle(30,30, 175, 175)
self.canvas.pack()
tkinter.mainloop()
shape = myShape()
a.
self.main_window = tkinter.Tk()

b.
self.canvas = tkinter.Canvas(self.main_window,width=200, height=200)

c.
self.canvas.create_rectangle(30,30, 175, 175)

d.
shape = myShape()

ANS: B

18. Given the following code, what are the dimensions, in pixels, of the shape created?
import tkinter
class myShape:
def __init__(self):
self.main_window = tkinter.Tk()
self.canvas = tkinter.Canvas(self.main_window,
width=200, height=200)
self.canvas.create_rectangle(30,30, 175, 175)
self.canvas.pack()
tkinter.mainloop()
shape = myShape()
a.
200 X 200

b.
30 X 175

c.
145 X 145

d.
None of these

ANS: C

COMPLETION

1. A(n) __________ allows the user to interact with the operating system and other programs through graphical elements on the screen.

ANS: GUI

2. The GUI popularized the use of the __________ as an input device.

ANS: mouse

3. __________ are small windows that display information and allow the user to perform actions.

ANS: Dialog boxes

4. Since GUI programs respond to the actions of the user, they are called __________ programs.

ANS: event-driven

5. The __________ module allows you to create GUI programs in Python.

ANS: tkinter

6. The __________ widget is used to display text in a window.

ANS: Label

7. The Label widget’s __________ method determines where a widget should be positioned and makes the widget visible when the main window is displayed.

ANS: pack

8. A(n) ___________ is a container that can hold other widgets and organize the widgets in a window.

ANS: Frame

9. A(n) __________ function is a function or method that executes when the user clicks a button.

ANS: callback, event handler

10. A(n) __________ is a widget that the user can click to cause an action to occur.

ANS: Button

11. The __________ widget provides methods that allow the programmer to draw some simple shapes.

ANS: Canvas

12. To create a line with the create_line method of the Canvas widget, you must include four arguments that represent beginning and ending __________.

ANS: coordinates