An Introduction to Interactive Programming in Python - Week three
3475 ワード
Canvas — Canvas and drawing The canvas is the area associated with an application where information contain in the application may be drawn. In SimpleGUI applications, the width and height of the canvas are specified (in pixels) in The origin for the canvas is the upper left-hand corner. Positions in the canvas are specified as pairs Lecture examples - Canvas and Drawing More examples - Structure
Event-driven drawing — Canvas and drawing Computers refresh their screens around 60 times per sec. For each application, the computer calls a special event handler, the draw handler, that is registered to the application. In SimpleGUI, the draw handler is registered via The draw handler can modify the canvas via simple draw operations defined in SimplGUI Lecture examples - Canvas and Drawing More examples - Structure, Echo
String operations — String processing The function The concatenation operator The Substrings of Lecture examples - Strings, Dollars and Cents One, Dollars and Cents Two More examples - Operations, Input Checking, Initials
Drawing text — Interactive drawing The method The method The method The method Colors for drawing methods can be specified as HTML color strings; Lecture examples - Drawing, Interactive Drawing More examples - Shapes, Pictures, Hidden Picture
Timers — Timers Timers are another component of SimpleGUI that generate regularly timed events. Users create a timer using The timer calls its associated event handler regularly at the given interval. A timer Lecture examples - Timers More examples - Blinking Text, Reaction Time
Programming Tips — Week 3 (pt. 1), Week 3 (pt. 2)
from: https://class.coursera.org/interactivepython-005/wiki/view?page=week3
create_frame
. (A pixel is the smallest unit of area that your computer can draw in.) [x,y]
where x
is the horizontal coordinate and y
is the vertical coordinate. Event-driven drawing — Canvas and drawing
set_draw_handler
. String operations — String processing
str
converts other types of data into a string. +
joins two strings to form a single string, i
th element of a string my_string
can be access via my_string[i]
. Note that strings are immutable (cannot be changed). my_string
can be accessed via slicing . Drawing text — Interactive drawing
draw_text
draws a string when given a position (lower left corner), a font size and a color. draw_circle
(see "More examples"below) draws a circle at a given point with a given radius in pixels. To draw a point, draw a circle of radius one. draw_line
(see "More examples"below) draws a line between two points. draw_polygon
(see "More examples"below) draws a sequence of points (enclosed in square brackets and separated by commas) as a closed polygon. "White", "Red", "Green", ...
Timers — Timers
create_timer
with a specified interval and event handler. t
is started with t.start()
and is stopped by t.stop()
. Programming Tips — Week 3 (pt. 1), Week 3 (pt. 2)
from: https://class.coursera.org/interactivepython-005/wiki/view?page=week3