Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 408/508: Programming for Linguists Lecture 23 November 25 th.

Similar presentations


Presentation on theme: "LING 408/508: Programming for Linguists Lecture 23 November 25 th."— Presentation transcript:

1 LING 408/508: Programming for Linguists Lecture 23 November 25 th

2 Last Time Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics library) – built on top of X11 (graphics library) on Ubuntu

3 graphics.py

4 Object inheritance (see graphics.py code): GraphicsObject – Point: draw, move, clone – Text: clone, move, draw, setText, getText, setFace – Polygon: clone, getPoints, move, draw – _Bbox: move Rectangle: draw Oval: clone, draw – Circle: clone, getRadius Line: clone, draw, setArrow

5 Directly in wish tcl/tk Stylistic variation… graphics.py : use primitive object Point tk : uses plain x,y coordinates

6 Interactive Graphics textbook 5.7: –p = win.getMouse() returns a Point

7 Interactive Graphics

8

9 textbook 5.7: –input = Entry(center,width) creates a user- editable text box

10 Interactive Graphics

11

12 graphics.py API

13

14

15 Color: Color names: – see http://wiki.tcl.tk/37701http://wiki.tcl.tk/37701

16 graphics.py API

17

18

19

20

21 Section 6.2-6.4 Happy birthday example nested function calls: Note: parameters are passed by value (copying) -not by reference (pointer) -(some other programming languages allow both options)

22 Section 6.5 To send a value back, use – return Multiple values can be returned: Note: None is returned when there is no return statement

23 triangle2.py Calculates the perimeter of a triangle you draw.

24 triangle2.py Note: parameters are passed by value (copying) -mutable objects (Point)

25 triangle2.py


Download ppt "LING 408/508: Programming for Linguists Lecture 23 November 25 th."

Similar presentations


Ads by Google