Week 2: Interactive Applications In Python Flashcards

1
Q

Event-Dirven Programming Model?

A

Program Starts, initializes, and “waits” for something to happen - it does not require one specific thing to happen, but will react based on what does happen.

These “events” are executed by “handlers”.

The program ends when a “quit” event occurs.

The key difference is the event-driven programming model is centred on a default of waiting.

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

Types of Events in Event-Driven Programming model? (4)

A

Input (Button, Text box)
Keyboard (Key down, key up)
Mouse (Click, drag)
Timer (count up, countdown)

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

Event Queue?

A

When an event occurs in Python code, it goes into the event queue. The program looks to see what’s next in the queue and pairs it to the appropriate handler, then looks at the queue again so every event occurs in order.

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

Global vs Local Variables?

A

Global Variables take place outside of any functions and can be used by all of the functions. Local variables are created in, and used by, a single function.

Global variables can be modified in functions without affecting their values outside of the function Eg. changing the value in the function only

In a function, can modify a global variable by leading with the term “global, then the variable, and then the new definition.
Eg. global num
num = 5

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

What is a Handler?

A

A handler is a function that launches in response to an event and will run the expected outcome from the event,

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

What is the recommended Python program structure? (7 Steps)

A
Globals
Helper Functions
Classes
Define Event Handlers
Create a Frame
Register Event Handlers
Start Frame & Timers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In a Python GUI, when a user pushes a button, what argument is passed to the event handler?

A

Answer Nothing - there are no arguments passed to an event handler for a button;

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