Chapter 8 Flashcards

1
Q

Graphical User Interfaces (GUI)

A

Displays text, small images (icons), that represent objects such as directories, files of diff types, command buttons and drop-down menus

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Terminal-Based version

A
  • user is constrained to reply to a definite sequence of prompts for inputs - once input entered, no way to change it
  • To obtain results for a different set of input data, user must wait for command menu
    to be displayed again - At that point, the same command and all of the other inputs must be re‐entered
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

GUI- Based version

A
  • displays window that contains various components - window objects or widgets
  • effects on users
    a. user not constrained to enter inputs in particular order - Before pressing the Compute button, user can edit any of the data
    b. Running different data sets does not require re‐entering all of the data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Event-Driven Programming

A

User- generated events (e.g., mouse clicks) trigger ops in program to respond by pulling in inputs, processing them, and displaying results
- Event-driven software
- Event-driven programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Event-Driven Programming Coding phase

A
  1. Define a new class to represent the main window
  2. Instantiate the classes of window objects needed for this application (e.g., labels,
    command buttons)
  3. Position these components in the window
  4. Instantiate the data model and provide any default data in the window objects
  5. Register controller methods with each window object in which a relevant event might
    occur
  6. Define these controller methods
  7. Define a main that launches the GUI
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

tkinter

A

module that includes classes for windows and numerous types of window objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

breezypythongui

A

custom, open-source module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

EasyFrame

A
  • class that provides the basic functionality for any window, such as the command buttons in the title bar
  • a new window class extends it (meaning provides additional functionality
  • subclass of tkinter’s Frame class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Template of GUI program

A

from breezypythongui import EasyFrame
Other imports
class ApplicationName(EasyFrame):
The __init__ method definition
Definitions of event handling methods
def main():
ApplicationName().mainloop()
if __name__ == “__main__”:
main()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Syntax of Class and Method Definitions

A
  • Each def has a 1 line header beginning with keyword (class/def) - followed by body of code indented 1 level in the text
  • class header: name of class folowed by parenthesized list of one or more parent classes
  • body: nested 1 tab under header, 1 or more method defs
  • method header: looks like function header but always has at least 1 parameter named self
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

subclass

A
  • class that inherits attributes & behaviors from another class
    ie.
    EasyFrame is a subclass of Frame, and classes LabelDemo or whatever new class is created is a subclass of EasyFrame
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Window attributes

A
  • Title (an empty string by default)
  • Width & height in pixels
  • resizability (true by default)
  • background color (white by default)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Window layout

A
  • window components laid out in 2 dimensional grid - rows/columns numbered from position (0,0) in upper left corner of window
  • each type of window component has default alignment
  • default alignment can be overrode with “sticky”
  • an aspect of window layout involves spanning of a window component across several grid positions
  • horizontal/vert spanning of grid can be forced by supplying rowspan and columnspan
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Methods in breezypythongui

A
  • methods for adding each type of window component to a window
  • each method uses this form:
    self.addComponentType(<arguments>)</arguments>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What happens when a method in breezypythongui is called?

A
  1. breezypythongui creates an instance of the requested type of window component
  2. initializes component’s attributes with default values or any values provided by programmer
  3. places the component in its grid position (row & column are required arguments)
  4. returns a reference to the component
How well did you know this?
1
Not at all
2
3
4
5
Perfectly