An Introduction to Interactive Programming in Python (Part 1)
1.4.1example of drawing on the canvas：1，2，3
Week 2 Quiz
- What typically calls an event handler?
A. The code you write.
B. Some code that you didn’t write which generates the event.
解：B. An event handler typically is a software routine that processes actions such as keystrokes and mouse movements. 可以理解为监视器，这显然是不需要自己写的，直接用就可以。
- What are the three parts of a frame?
Refer to the video on SimpleGUI.
- Refer to the video on SimpleGUI.
- Options Area
- Status Area
- Background Area
- Control Area
解：Canvas（画布）Status Area（状态区域） Control Area（控制区域）
Control area is where we have buttons, text inputs, and there are even text labels that allow you to print status information from your application back to the frame. In this application, there’s just this one button that says click me, so let’s click it. And you’ll notice over on the right hand side, which is the canvas, the message changed from welcome to good job.
Canvas, is where all the interesting things are going to happen in your program. This is where we can draw images, shapes, text, and we can even respond to keyboard and mouse events over in the canvas. So, the canvas is the interesting part of the frame.
Status area :the status area gives us feedback about keyboard and mouse events that happen in the canvas and this is critical to making the bugging a little bit simpler in SimpleGUI. So now you seen the basic application on this elements.
3.注意list a 的变化，直接将a赋给b,a是会随着b变化的。
make a new reference b to a.
a = [5, 3, 1, -1, -3, 5] b = a b = 0 print a print b #[0, 3, 1, -1, -3, 5] #[0, 3, 1, -1, -3, 5]
make a new copy b of the list a using the function list.
# The assignment b = list(a) created a copy of the list a. # Setting b = 0 only mutated the copy of the list, not # the original list. As a result, a == 5. a = [5, 3, 1, -1, -3, 5] b = list(a) b = 0 print a print b #[5, 3, 1, -1, -3, 5] #[0, 3, 1, -1, -3, 5]