![Page 1: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/1.jpg)
LING408/508:ProgrammingforLinguists
Lecture23
November25th
![Page 2: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/2.jpg)
LastTime
• Librarygraphics.py– builtontopofTkinter(PythoninterfacetoTk)– builtontopofTk(graphicslibrary)– builtontopofX11(graphicslibrary)onUbuntu
![Page 3: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/3.jpg)
graphics.py
![Page 4: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/4.jpg)
graphics.py• Objectinheritance(seegraphics.pycode):• 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
![Page 5: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/5.jpg)
Directlyinwishtcl/tk !
Stylis'cvaria'on…graphics.py:useprimiWveobjectPoint!tk:usesplainx,ycoordinates
![Page 6: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/6.jpg)
InteracWveGraphics
• textbook5.7:– p = win.getMouse() returnsaPoint
![Page 7: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/7.jpg)
InteracWveGraphics
![Page 8: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/8.jpg)
InteracWveGraphics
![Page 9: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/9.jpg)
InteracWveGraphics
• textbook5.7:– input = Entry(center,width)
createsauser-editabletextbox
![Page 10: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/10.jpg)
InteracWveGraphics
![Page 11: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/11.jpg)
InteracWveGraphics
![Page 12: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/12.jpg)
graphics.pyAPI
![Page 13: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/13.jpg)
graphics.pyAPI
![Page 14: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/14.jpg)
graphics.pyAPI
![Page 15: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/15.jpg)
graphics.pyAPI• Color:
• Colornames:– seehZp://wiki.tcl.tk/37701
![Page 16: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/16.jpg)
graphics.pyAPI
![Page 17: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/17.jpg)
graphics.pyAPI
![Page 18: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/18.jpg)
graphics.pyAPI
![Page 19: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/19.jpg)
graphics.pyAPI
![Page 20: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/20.jpg)
graphics.pyAPI
![Page 21: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/21.jpg)
SecWon6.2-6.4
• Happybirthdayexample
• nestedfuncWoncalls:
Note:parametersarepassedbyvalue(copying)- notbyreference(pointer)- (someotherprogramminglanguagesallowbothopWons)
![Page 22: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/22.jpg)
SecWon6.5
• Tosendavalueback,use– return<Expression>
• MulWplevaluescanbereturned:
Note:Noneisreturnedwhenthereisnoreturnstatement
![Page 23: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/23.jpg)
triangle2.py• Calculatestheperimeterofatriangleyoudraw.
![Page 24: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/24.jpg)
triangle2.py !
Note:parametersarepassedbyvalue(copying)- mutableobjects(Point)
![Page 25: LING 408/508: Programming for Linguistssandiway/ling508-15/...Last Time • Library graphics.py – built on top of Tkinter (Python interface to Tk) – built on top of Tk (graphics](https://reader035.vdocuments.net/reader035/viewer/2022062507/5fc5a8f4e444897e191ad0e5/html5/thumbnails/25.jpg)
triangle2.py !