Kc@sdZdZeZeZdZddkZddk Z ddk Z ddk ZddkZddkZddkZddkZddkZddkZddkZddkZyeWn1yddk l!ZWne"dnXnXedjo eZne i#Z$e$i%dd fd YZ&d e'fd YZ(d e)fdYZ*de)fdYZ+de)fdYZ,de)fdYZ-de)fdYZ.de)fdYZ/de/fdYZ0de)fdYZ1dei2fdYZ3dei2fd YZ4d!e-e1fd"YZ5d#e1fd$YZ6d%e6e-fd&YZ7d'e6fd(YZ8d)e8fd*YZ9d+e9fd,YZ:d-e9fd.YZ;d/e9fd0YZ<d1e<fd2YZ=d3e8fd4YZ>d5e>e9fd6YZ?d7e8fd8YZ@d9e@e9fd:YZAd;e6fd<YZBd=e6fd>YZCd?eCe<e/fd@YZDdAeCe<e/fdBYZEdCe1fdDYZFdEei2fdFYZGdGe)fdHYZHedjoyddkIZJy.ddkBZKddkLZMddkNZOeZPWn eZPnXeQaRdIe&fdJYZSeSZTdKe)fdLYZUdMZVdNe)fdOYZWdPeWfdQYZXdReXfdSYZYdTeYfdUYZZdVeYfdWYZ[dXeXfdYYZ\dZeYfd[YZ]d\eXfd]YZ^d^eYfd_YZ_d`eWfdaYZ`dbeWfdcYZaddZbdeZceQaRWnedj o dfGHnXnedjondgGHdhZeeTafeo!eigecfeiheenebdS(iscs1graphics.py Copyright 2007, 2008 David Letscher and Michael H. Goldwasser Go to www.cs1graphics.org for more information. Version 1.1: 5/25/2008 Version 1.1.1: 01/22/2010 (bug fix in Drawable.flip) itTkinteriN(tSets/Cannot find set class; Use Python 2.3 or latertPILit_GraphicsManagercBsneZdZedZdZdZdZdZdZ dZ dZ d Z d Z RS( cCst|_ti|_ti|_ti|_ti|_ t |_ t |_ d|_t |_t |_t |_t |_t |_t|_t |_t|_d|_t|_t|_dS(N(tTruet_runningt_QueuetQueuet _commandQueuet _releaseQueuet _eventQueuet _threadingtLockt _refreshLocktdictt_underlyingObjectttuplet _currentChaintNonet_currentCanvast_transformChaint _transformt _renderOrdert _canvasest_chainstsett _openCanvasest _handlerst_waitingTriggerst_mousePrevPositiontFalset_mouseButtonDownt _forceUpdates(tself((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt__init__Bs&              cCsXto(|io|ii||fq?n|i|||o|iiSdS(N(t _enableEventsRRtputtprocessCommandR tget(R!tcommandtblocking((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytaddCommandToQueuecs  cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt _closeAlllsc CsCyx|io|iidjo|iid\}}y|i||Wqtj oI}|iGH|ipt|_|q|o|i i dqqXqWWnt i j o&tdjodGHt|_q?nYtdjotidtindGHdGHt|_|i|i i dnXdS(NiisQueue empty exceptiontfilesGUnknown graphics error has occured. Graphics manager is shutting down.s*Program must be restarted to use graphics.(RRtqsizeR&R%t GraphicsErrortmessaget _recoverableRR R$RRtEmptyt_debugt _tracebackt print_exct_syststdoutR*(R!R'R(tge((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytprocessCommandsos2    "    c Cs tdjoHdG|G|GHntdjo*dG|iGHydG|iGHWqVqVXnd}|ddjo\t|d|d|d|d |d |d |d_|d |i|ddffd&}|i?i@dWqw tAd'tqw Xn|o|i?i@|ndS((NisManager executing:isCurrent chain:s Update infois create canvasiiiiis update canvass close canvass open canvass begin refreshscomplete refreshs set chains save to files begin drawiis complete draws draw circlesdraw rectangles draw paths draw polygons draw splinesdraw closed splines draw texts get text sizettexttfontt Helveticatnormals draw images load imagetRGBAsUnable to open image file(BR1Rt_needsUpdatingInfoRt_RenderedCanvast_canvasRt setHeighttsetWidthtsetBackgroundColortsetTitlet_graphicsManagerRtkeystremoveUnderlyingt_tkroottupdatet_tkWintwithdrawt deiconifyt_transformationChainRt_forceRR tlistRRt _chainCountRt_tranformationChainRt_prevRenderOrdertindext saveToFileR&Rthas_keytaddRtlenRtappendt_RenderedCirclet_RenderedRectanglet _RenderedPatht getPointst_RenderedPolygont_RenderedSplinet_RenderedClosedSplinet _RenderedTextt_TkintertTopleveltCanvast create_texttbboxtdeletet_RenderedImaget _pilAvailablet PhotoImaget_ImagetopentconvertR R$R-(R!R'R(tresultREtktitemtxtitchainR8tsizettkWintcanvasRdtimage((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR%s   :"     /         #<19$ (& %+ %+ %; %; %; %; %.   '  ( %.cCstdjo3dG|G|ii|tG|G|G|G|GHnx|ii|tD]}|iotdjodG|i||fGHn| o7to0|itt|i||f|||q|itdt t t qYqYWdS(NisObject changed:sChains for update:( R1RR&RNt _autoRefreshRRt _trueRefreshRRR(R!tdrawabletpositiont propertiestdepthtcan((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt objectChangedGs 3  0cCsdS(N((R!Rq((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRFTscCs}toc|ii|o<||i|jo|i|i|qftdqy|g|i|').t(tstrRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt__str__scCsAt|tptdnt|i|i|i|iS(s?Return a new point that is the sum of this Point and the other.s%both operands must be Point instances(RRRRR(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt__add__scCsot|ttfot|i||i|St|to|i|i|i|iStddS(s.Return the result when multiplying the Point by an operand. When the operand is a scalar (i.e., an int or float), return a Point that has coordinates equal to the original times the factor. When operand is another Point, return a scalar that is the dot product of the two points. s%unexpected operand for multiplicationN(RRRRRRR(R!toperand((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt__mul__s cCs||S(s^Return the result when multiplying the Point by an operand. See __mul__ for details. ((R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt__rmul__scCst|ttfptdnti|d}ti|i|i|i|i}t |iti ||iti ||iti ||iti |S(sReturn a new point instance representing the original, rotated about the origin. angle number of degrees of rotation (clockwise) s numeric value expected for anglegf@( RRRRRtpiRRRRtcostsin(R!tangleR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt__xor__s '(RRt__doc__R"RRRRR&RRRRRRRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRws           t_TransformationcBseeZd dZdZdZdZdZdZdZ dZ dZ d Z RS( cCs;|o|d |_|d|_nd|_d|_dS(Nig?g(g?ggg?(gg(t_matrixt _translation(R!tvalue((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s   cCs:dttt|dt|it|ifS(Ns _Transformation s%: matrix = %s translation = %s (RthextidtreprRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt__repr__s(cCsct|id|i|id|i|id|id|i|id|i|idS(Niiii(RRRRR(R!tpoint((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRus1cCsd|i}|id||id ||id ||id|f}|d |id|d|id|d |id|d|idf}t||S(Ng?iiii(tdetRRR(R!tdetinvtmtt((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytinvs@RcCs|id|id|id|id|id|id|id|id|id|id|id|id|id|id|id|idf}|it|id|id}t||i|ifS(Niiii(RRuRRRRR(R!RRtp((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs +++1&cCs,|id|id|id|idS(Niiii(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCstit|iS(N(RRtabsR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR scCsP|id|idjo1|id|idjo djnotStS(Niiii(RRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytscaleAndTranslate sGcCs5|id|idjo djnotStS(Niii(RRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytdiagonalAndTranslates,cCsa|id|idjo djno1|id|idjo djnotStS(Niiii(RRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt translateOnlysXN( RRRR"RRuRRRRRRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs        tColorcBs}eZdZhdd6dd6dd 6dd6dd6dd6dd6dd6dd6dd!6dd$6dd%6dd&6dd(6dd*6dd+6dd.6dd16dd26dd56dd76dd:6dd<6dd=6dd>6dd?6dd@6ddA6ddB6ddF6ddI6ddK6ddM6ddO6ddQ6ddU6ddX6dd[6dd\6dd_6ddb6ddd6ddg6ddi6ddl6ddm6ddn6ddo6ddp6ddq6ddu6ddw6ddy6dd{6dd}6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d d 6d d 6d d6d d6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd!6dd"6dd#6dd$6dd&6dd'6dd)6dd*6dd+6d d,6d!d.6d"d/6d#d06d$d16d%d36d&d46d'd66d(d76d)d96d*d:6d+d<6d,d>6d-d?6d.d@6d/dA6d0dC6d1dD6d2dF6d3dH6d4dI6d5dK6d6dL6d7dM6d8dO6d9dQ6d:dS6d;dU6d<dW6d=dY6d>d[6d?d\6d@d]6dAd^6dBd_6dCd`6dDda6dEdb6dFdc6dGdd6dHde6dIdf6dJdh6dKdi6dLdk6dMdm6dNdn6dOdo6dPdp6dQdq6dRdr6dSds6dTdt6dUdu6dVdv6dWdx6dXdy6dYd{6dZd}6d[d6d\d6d]d6d^d6d_d6d`d6dad6dbd6dcd6ddd6ded6dfd6dgd6dhd6did6djd6dkd6dld6dmd6dnd6dod6dpd6dqd6drd6dsd6dtd6dud6dvd6dwd6dxd6dyd6dzd6d{d6d|d6d}d6d~d6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd 6dd 6dd 6dd 6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd!6dd"6dd#6dd$6dd%6dd&6dd(6dd*6dd,6dd-6dd.6dd/6dd06dd16dd26dd36dd46dd56dd66dd86dd:6dd;6dd<6dd=6dd>6dd?6dd@6d dA6d dB6d dC6d dE6d dF6ddG6ddH6ddI6ddJ6ddL6ddM6ddN6ddO6ddP6ddR6ddS6ddT6ddU6ddV6ddW6ddY6dd[6dd\6d d]6d!d`6d"da6d#db6d$dc6d%dd6d&df6d'dh6d(di6d)dj6d*dk6d+dl6d,dm6d-dn6d.do6d/dp6d0dq6d1dr6d2ds6d3du6d4dv6d5dx6d6dz6d7d|6d8d}6d9d~6d:d6d;d6d<d6d=d6d>d6d?d6d@d6dAd6dBd6dCd6dDd6dEd6dFd6dGd6dHd6dId6dJd6dKd6dLd6dMd6dNd6dOd6dPd6dQd6dRd6dSd6dTd6dUd6dVd6dWd6dXd6dYd6dZd6d[d6d\d6d]d6d^d6d_d6d`d6dad6dbd6dcd6ddd6ded6dfd6dgd6dhd6did6djd6dkd6dld6dmd6dnd6dod6dpd6dqd6drd6dsd6dtd6dud6dvd6dwd6dxd6dyd6dzd6d{d6d|d6d}d6d~d6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd 6dd 6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd!6dd"6dd#6dd$6dd&6dd'6dd(6dd)6dd*6dd+6dd,6dd.6dd/6dd06dd16dd36dd56dd66dd76dd86dd96dd:6dd;6dd<6dd=6dd>6dd?6dd@6ddA6ddB6ddC6ddD6ddE6ddF6ddG6ddI6ddJ6ddL6ddM6ddN6ddO6ddP6ddR6ddS6ddT6ddU6ddV6ddW6ddX6ddY6ddZ6dd[6dd\6dd]6dd^6dd`6dda6ddb6ddc6ddd6dde6ddf6ddg6ddh6ddi6ddj6d dk6d dm6d dn6d do6d dp6ddq6ddr6dds6ddt6ddu6ddv6ddw6ddx6ZdydzZd{Zd|Zd}Zd~ZdZ dZ e e Z dZ dZ dZdZRS(sA color representation. A color can be specified by name or RGB value, and can be made transparent. Available colors are: aliceblue, antiquewhite, antiquewhite1, antiquewhite2, antiquewhite3, antiquewhite4, aquamarine, aquamarine1, aquamarine2, aquamarine3, aquamarine4, azure, azure1, azure2, azure3, azure4, beige, bisque, bisque1, bisque2, bisque3, bisque4, black, blanchedalmond, blue, blue1, blue2, blue3, blue4, blueviolet, brown, brown1, brown2, brown3, brown4, burlywood, burlywood1, burlywood2, burlywood3, burlywood4, cadetblue, cadetblue1, cadetblue2, cadetblue3, cadetblue4, chartreuse, chartreuse1, chartreuse2, chartreuse3, chartreuse4, chocolate, chocolate1, chocolate2, chocolate3, chocolate4, coral, coral1, coral2, coral3, coral4, cornflowerblue, cornsilk, cornsilk1, cornsilk2, cornsilk3, cornsilk4, cyan, cyan1, cyan2, cyan3, cyan4, darkblue, darkcyan, darkgoldenrod, darkgoldenrod1, darkgoldenrod2, darkgoldenrod3, darkgoldenrod4, darkgray, darkgreen, darkgrey, darkkhaki, darkmagenta, darkolivegreen, darkolivegreen1, darkolivegreen2, darkolivegreen3, darkolivegreen4, darkorange, darkorange1, darkorange2, darkorange3, darkorange4, darkorchid, darkorchid1, darkorchid2, darkorchid3, darkorchid4, darkred, darksalmon, darkseagreen, darkseagreen1, darkseagreen2, darkseagreen3, darkseagreen4, darkslateblue, darkslategray, darkslategray1, darkslategray2, darkslategray3, darkslategray4, darkslategrey, darkturquoise, darkviolet, deeppink, deeppink1, deeppink2, deeppink3, deeppink4, deepskyblue, deepskyblue1, deepskyblue2, deepskyblue3, deepskyblue4, dimgray, dimgrey, dodgerblue, dodgerblue1, dodgerblue2, dodgerblue3, dodgerblue4, firebrick, firebrick1, firebrick2, firebrick3, firebrick4, floralwhite, forestgreen, gainsboro, ghostwhite, gold, gold1, gold2, gold3, gold4, goldenrod, goldenrod1, goldenrod2, goldenrod3, goldenrod4, gray, gray0, gray1, gray10, gray100, gray11, gray12, gray13, gray14, gray15, gray16, gray17, gray18, gray19, gray2, gray20, gray21, gray22, gray23, gray24, gray25, gray26, gray27, gray28, gray29, gray3, gray30, gray31, gray32, gray33, gray34, gray35, gray36, gray37, gray38, gray39, gray4, gray40, gray41, gray42, gray43, gray44, gray45, gray46, gray47, gray48, gray49, gray5, gray50, gray51, gray52, gray53, gray54, gray55, gray56, gray57, gray58, gray59, gray6, gray60, gray61, gray62, gray63, gray64, gray65, gray66, gray67, gray68, gray69, gray7, gray70, gray71, gray72, gray73, gray74, gray75, gray76, gray77, gray78, gray79, gray8, gray80, gray81, gray82, gray83, gray84, gray85, gray86, gray87, gray88, gray89, gray9, gray90, gray91, gray92, gray93, gray94, gray95, gray96, gray97, gray98, gray99, green, green1, green2, green3, green4, greenyellow, grey, grey0, grey1, grey10, grey100, grey11, grey12, grey13, grey14, grey15, grey16, grey17, grey18, grey19, grey2, grey20, grey21, grey22, grey23, grey24, grey25, grey26, grey27, grey28, grey29, grey3, grey30, grey31, grey32, grey33, grey34, grey35, grey36, grey37, grey38, grey39, grey4, grey40, grey41, grey42, grey43, grey44, grey45, grey46, grey47, grey48, grey49, grey5, grey50, grey51, grey52, grey53, grey54, grey55, grey56, grey57, grey58, grey59, grey6, grey60, grey61, grey62, grey63, grey64, grey65, grey66, grey67, grey68, grey69, grey7, grey70, grey71, grey72, grey73, grey74, grey75, grey76, grey77, grey78, grey79, grey8, grey80, grey81, grey82, grey83, grey84, grey85, grey86, grey87, grey88, grey89, grey9, grey90, grey91, grey92, grey93, grey94, grey95, grey96, grey97, grey98, grey99, honeydew, honeydew1, honeydew2, honeydew3, honeydew4, hotpink, hotpink1, hotpink2, hotpink3, hotpink4, indianred, indianred1, indianred2, indianred3, indianred4, ivory, ivory1, ivory2, ivory3, ivory4, khaki, khaki1, khaki2, khaki3, khaki4, lavender, lavenderblush, lavenderblush1, lavenderblush2, lavenderblush3, lavenderblush4, lawngreen, lemonchiffon, lemonchiffon1, lemonchiffon2, lemonchiffon3, lemonchiffon4, lightblue, lightblue1, lightblue2, lightblue3, lightblue4, lightcoral, lightcyan, lightcyan1, lightcyan2, lightcyan3, lightcyan4, lightgoldenrod, lightgoldenrod1, lightgoldenrod2, lightgoldenrod3, lightgoldenrod4, lightgoldenrodyellow, lightgray, lightgreen, lightgrey, lightpink, lightpink1, lightpink2, lightpink3, lightpink4, lightsalmon, lightsalmon1, lightsalmon2, lightsalmon3, lightsalmon4, lightseagreen, lightskyblue, lightskyblue1, lightskyblue2, lightskyblue3, lightskyblue4, lightslateblue, lightslategray, lightslategrey, lightsteelblue, lightsteelblue1, lightsteelblue2, lightsteelblue3, lightsteelblue4, lightyellow, lightyellow1, lightyellow2, lightyellow3, lightyellow4, limegreen, linen, magenta, magenta1, magenta2, magenta3, magenta4, maroon, maroon1, maroon2, maroon3, maroon4, mediumaquamarine, mediumblue, mediumorchid, mediumorchid1, mediumorchid2, mediumorchid3, mediumorchid4, mediumpurple, mediumpurple1, mediumpurple2, mediumpurple3, mediumpurple4, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, mistyrose1, mistyrose2, mistyrose3, mistyrose4, moccasin, navajowhite, navajowhite1, navajowhite2, navajowhite3, navajowhite4, navy, navyblue, oldlace, olivedrab, olivedrab1, olivedrab2, olivedrab3, olivedrab4, orange, orange1, orange2, orange3, orange4, orangered, orangered1, orangered2, orangered3, orangered4, orchid, orchid1, orchid2, orchid3, orchid4, palegoldenrod, palegreen, palegreen1, palegreen2, palegreen3, palegreen4, paleturquoise, paleturquoise1, paleturquoise2, paleturquoise3, paleturquoise4, palevioletred, palevioletred1, palevioletred2, palevioletred3, palevioletred4, papayawhip, peachpuff, peachpuff1, peachpuff2, peachpuff3, peachpuff4, peru, pink, pink1, pink2, pink3, pink4, plum, plum1, plum2, plum3, plum4, powderblue, purple, purple1, purple2, purple3, purple4, red, red1, red2, red3, red4, rosybrown, rosybrown1, rosybrown2, rosybrown3, rosybrown4, royalblue, royalblue1, royalblue2, royalblue3, royalblue4, saddlebrown, salmon, salmon1, salmon2, salmon3, salmon4, sandybrown, seagreen, seagreen1, seagreen2, seagreen3, seagreen4, seashell, seashell1, seashell2, seashell3, seashell4, sienna, sienna1, sienna2, sienna3, sienna4, skyblue, skyblue1, skyblue2, skyblue3, skyblue4, slateblue, slateblue1, slateblue2, slateblue3, slateblue4, slategray, slategray1, slategray2, slategray3, slategray4, slategrey, snow, snow1, snow2, snow3, snow4, springgreen, springgreen1, springgreen2, springgreen3, springgreen4, steelblue, steelblue1, steelblue2, steelblue3, steelblue4, tan, tan1, tan2, tan3, tan4, thistle, thistle1, thistle2, thistle3, thistle4, tomato, tomato1, tomato2, tomato3, tomato4, turquoise, turquoise1, turquoise2, turquoise3, turquoise4, violet, violetred, violetred1, violetred2, violetred3, violetred4, wheat, wheat1, wheat2, wheat3, wheat4, white, whitesmoke, yellow, yellow1, yellow2, yellow3, yellow4, yellowgreen iiit aliceblueiiit antiquewhiteiit antiquewhite1iiit antiquewhite2iiit antiquewhite3iiixt antiquewhite4iit aquamarinet aquamarine1ivit aquamarine2ifit aquamarine3iEitt aquamarine4tazuretazure1itazure2itazure3tazure4iitbeigeiitbisquetbisque1iitbisque2itbisque3i}iktbisque4itblacktblanchedalmondtbluetblue1tblue2tblue3tblue4ii+it bluevioletii*tbrowni@tbrown1i;tbrown2i3tbrown3i#tbrown4iiit burlywoodiit burlywood1iit burlywood2t burlywood3isiUt burlywood4i_it cadetblueit cadetblue1iit cadetblue2izt cadetblue3iSit cadetblue4t chartreuset chartreuse1t chartreuse2t chartreuse3t chartreuse4iiiit chocolatei$t chocolate1i!t chocolate2it chocolate3it chocolate4iPtcoraliriVtcoral1ijtcoral2i[tcoral3i>i/tcoral4idiitcornflowerbluetcornsilkt cornsilk1it cornsilk2iit cornsilk3it cornsilk4tcyantcyan1tcyan2tcyan3tcyan4tdarkbluetdarkcyani t darkgoldenrodiitdarkgoldenrod1iitdarkgoldenrod2i tdarkgoldenrod3ieitdarkgoldenrod4itdarkgrayt darkgreentdarkgreyit darkkhakit darkmagentatdarkolivegreeniiptdarkolivegreen1iihtdarkolivegreen2iiZtdarkolivegreen3ini=tdarkolivegreen4it darkoranget darkorange1t darkorange2t darkorange3t darkorange4ii2t darkorchidit darkorchid1ii:t darkorchid2it darkorchid3i"t darkorchid4tdarkrediit darksalmonit darkseagreent darkseagreen1it darkseagreen2t darkseagreen3t darkseagreen4iHt darkslateblueiOt darkslategrayitdarkslategray1itdarkslategray2iytdarkslategray3iRtdarkslategray4t darkslategreyiit darkturquoiseit darkvioletiitdeeppinkt deeppink1iit deeppink2it deeppink3i t deeppink4t deepskybluet deepskyblue1t deepskyblue2t deepskyblue3t deepskyblue4tdimgraytdimgreyit dodgerbluet dodgerblue1it dodgerblue2it dodgerblue3iNt dodgerblue4t firebricki0t firebrick1i,t firebrick2i&t firebrick3it firebrick4t floralwhitet forestgreent gainsborot ghostwhitetgoldtgold1itgold2tgold3iutgold4ii t goldenrodi%t goldenrod1t goldenrod2t goldenrod3t goldenrod4itgraytgray0itgray1tgray10tgray100tgray11itgray12tgray13tgray14tgray15i)tgray16tgray17i.tgray18tgray19itgray2tgray20i6tgray21i8tgray22tgray23tgray24tgray25iBtgray26tgray27iGtgray28iJtgray29tgray3iMtgray30tgray31tgray32iTtgray33iWtgray34iYtgray35i\tgray36i^tgray37iatgray38ictgray39tgray4tgray40tgray41tgray42tgray43tgray44tgray45tgray46tgray47tgray48tgray49i tgray5tgray50itgray51itgray52tgray53tgray54tgray55tgray56tgray57tgray58tgray59tgray6tgray60itgray61tgray62itgray63itgray64itgray65itgray66itgray67tgray68tgray69tgray7itgray70itgray71tgray72itgray73tgray74tgray75itgray76tgray77itgray78tgray79tgray8tgray80itgray81tgray82tgray83itgray84itgray85tgray86tgray87tgray88itgray89itgray9tgray90tgray91tgray92tgray93tgray94itgray95tgray96itgray97tgray98itgray99tgreentgreen1tgreen2tgreen3tgreen4t greenyellowtgreytgrey0tgrey1tgrey10tgrey100tgrey11tgrey12tgrey13tgrey14tgrey15tgrey16tgrey17tgrey18tgrey19tgrey2tgrey20tgrey21tgrey22tgrey23tgrey24tgrey25tgrey26tgrey27tgrey28tgrey29tgrey3tgrey30tgrey31tgrey32tgrey33tgrey34tgrey35tgrey36tgrey37tgrey38tgrey39tgrey4tgrey40tgrey41tgrey42tgrey43tgrey44tgrey45tgrey46tgrey47tgrey48tgrey49tgrey5tgrey50tgrey51tgrey52tgrey53tgrey54tgrey55tgrey56tgrey57tgrey58tgrey59tgrey6tgrey60tgrey61tgrey62tgrey63tgrey64tgrey65tgrey66tgrey67tgrey68tgrey69tgrey7tgrey70tgrey71tgrey72tgrey73tgrey74tgrey75tgrey76tgrey77tgrey78tgrey79tgrey8tgrey80tgrey81tgrey82tgrey83tgrey84tgrey85tgrey86tgrey87tgrey88tgrey89tgrey9tgrey90tgrey91tgrey92tgrey93tgrey94tgrey95tgrey96tgrey97tgrey98tgrey99thoneydewt honeydew1t honeydew2t honeydew3t honeydew4thotpinkthotpink1ithotpink2i`thotpink3ibthotpink4t indianredt indianred1t indianred2t indianred3t indianred4tivorytivory1tivory2tivory3tivory4itkhakiitkhaki1tkhaki2tkhaki3tkhaki4tlavendert lavenderblushtlavenderblush1tlavenderblush2tlavenderblush3tlavenderblush4i|t lawngreent lemonchiffont lemonchiffon1t lemonchiffon2t lemonchiffon3t lemonchiffon4it lightbluet lightblue1t lightblue2t lightblue3t lightblue4it lightcoralt lightcyant lightcyan1t lightcyan2t lightcyan3t lightcyan4itlightgoldenroditlightgoldenrod1tlightgoldenrod2tlightgoldenrod3iiLtlightgoldenrod4tlightgoldenrodyellowt lightgrayt lightgreent lightgreyit lightpinkit lightpink1t lightpink2t lightpink3t lightpink4t lightsalmont lightsalmon1t lightsalmon2t lightsalmon3t lightsalmon4t lightseagreent lightskybluet lightskyblue1it lightskyblue2t lightskyblue3i{t lightskyblue4itlightslateblueiwtlightslategraytlightslategreytlightsteelblueitlightsteelblue1tlightsteelblue2tlightsteelblue3tlightsteelblue4t lightyellowt lightyellow1t lightyellow2t lightyellow3t lightyellow4t limegreentlinentmagentatmagenta1tmagenta2tmagenta3tmagenta4tmarooni4tmaroon1tmaroon2tmaroon3tmaroon4tmediumaquamarinet mediumbluet mediumorchidt mediumorchid1t mediumorchid2t mediumorchid3i7t mediumorchid4t mediumpurplet mediumpurple1it mediumpurple2t mediumpurple3i]t mediumpurple4i<iqtmediumseagreentmediumslatebluetmediumspringgreentmediumturquoiseitmediumvioletredit midnightbluet mintcreamt mistyroset mistyrose1t mistyrose2t mistyrose3t mistyrose4tmoccasint navajowhitet navajowhite1t navajowhite2t navajowhite3t navajowhite4tnavytnavyblueitoldlacet olivedrabt olivedrab1t olivedrab2t olivedrab3t olivedrab4torangetorange1torange2torange3torange4t orangeredt orangered1t orangered2t orangered3t orangered4torchidtorchid1torchid2torchid3torchid4t palegoldenrodit palegreent palegreen1t palegreen2t palegreen3t palegreen4it paleturquoiseitpaleturquoise1tpaleturquoise2tpaleturquoise3tpaleturquoise4t palevioletredtpalevioletred1tpalevioletred2tpalevioletred3tpalevioletred4t papayawhipt peachpufft peachpuff1it peachpuff2t peachpuff3t peachpuff4i?tperutpinktpink1tpink2tpink3iltpink4tplumtplum1tplum2tplum3tplum4t powderbluetpurpletpurple1tpurple2tpurple3tpurple4tredtred1tred2tred3tred4t rosybrownt rosybrown1t rosybrown2t rosybrown3t rosybrown4iAt royalbluet royalblue1iCt royalblue2t royalblue3i't royalblue4t saddlebrowntsalmontsalmon1tsalmon2tsalmon3i9tsalmon4it sandybrowntseagreent seagreen1t seagreen2t seagreen3t seagreen4tseashellt seashell1t seashell2t seashell3t seashell4i-tsiennatsienna1tsienna2tsienna3tsienna4tskybluetskyblue1i~tskyblue2tskyblue3tskyblue4t slateblueiot slateblue1igt slateblue2t slateblue3t slateblue4t slategrayt slategray1t slategray2t slategray3t slategray4t slategreytsnowtsnow1tsnow2tsnow3tsnow4t springgreent springgreen1t springgreen2t springgreen3t springgreen4iFt steelbluet steelblue1it steelblue2t steelblue3t steelblue4ttanttan1iIttan2ttan3ttan4tthistletthistle1tthistle2tthistle3tthistle4ttomatottomato1ttomato2ttomato3ttomato4it turquoiset turquoise1t turquoise2t turquoise3t turquoise4tviolett violetredt violetred1t violetred2t violetred3t violetred4twheatitwheat1twheat2twheat3twheat4twhitet whitesmoketyellowtyellow1tyellow2tyellow3tyellow4t yellowgreentWhitecCsg|_t|to?y|i|Wqtj o}tt|qXnt|to?y|i|Wqtj o}tt|qXnEt|to(|i|_|i |_ |i |_ n t ddS(sCreate a new Color instance (default 'White'). The parameter can be either: - a string with the name of the color - an (r,g,b) tuple - an existing Color instance (which will be cloned) sInvalid color specificationN( t _drawablesRRt setByNameR~Rt setByValueRt _colorNamet _transparentt _colorValueR(R!t colorChoicetve((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"[s   cCst|tptdn|iidd|_|idjot|_d|_nMy&t |_t i |ii|_Wn#t j ot d|nX|idS( sSet the color to colorName. colorName a string representing a valid name If colorName is 'Transparent' the resulting color will not show up on a canvas. sstring expected as color namet tt transparentis%s is not a valid color nameN(iii(RRRtlowertreplaceRaRRbRcRRt _colorValuestKeyErrorR~t_informDrawables(R!t colorName((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR_ys   cCs|iS(s_Return the name of the color. If the color was set by RGB value, it returns 'Custom'. (Ra(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt getColorNamescCst|tptdnt|djotdnxb|D]Z}t|ttfptdqJd|jo djnptdqJqJWt|_d|_ ||_ |i d S( s>Set the color to the given tuple of (red, green, blue) values.s(r,g,b) tuple expectedis((r,g,b) tuple must have three componentsstuple entries must be numericiis#tuple entries must be from 0 to 255tCustomN( RRRRVR~RRRRbRaRcRm(R!trgbTupleR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR`s   cCs"|id|id|idfS(s:Return a tuple of the (red, green, blue) color components.iii(Rc(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt getColorValuescCs|iS(sIReturn a boolean variable indicating if the current color is transparent.(Rb(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt isTransparentscCs7ttiddtiddtiddfS(sReturn a random color.ii(Rt_randomtrandint(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt randomColorscCs)|idjo|iiS|iSdS(sLReturn the name of the color, if named. Otherwise return the (r,g,b) value.RpN(RaRcR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCs(||ijo|ii|ndS(s6Called to register a Drawable with this Color instanceN(R^RW(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt _registerscCs(||ijo|ii|ndS(s8Called to unregister a Drawable with this Color instanceN(R^R(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt _unregisterscCs"x|iD]}|iq WdS(sTWhen the Color instance has been mutated, we must inform those registered drawables.N(R^t_objectChanged(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRms (iii(iii(iii(iii(iii(iiix(iii(iii(ivii(ifii(iEiit(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(ii}ik(iii(iii(iii(iii(iii(iii(iii(ii+i(ii*i*(ii@i@(ii;i;(ii3i3(ii#i#(iii(iii(iii(iii}(iisiU(i_ii(iii(iii(izii(iSii(iii(iii(ivii(ifii(iEii(iiii(iii$(iivi!(iifi(iiEi(iiiP(iiriV(iijiP(ii[iE(ii>i/(idii(iii(iii(iii(iii(iiix(iii(iii(iii(iii(iii(iii(iii(iii (iii(iii(iii (iiei(iii(iidi(iii(iiik(iii(iUiki/(iiip(iiih(iiiZ(inii=(iii(iii(iivi(iifi(iiEi(ii2i(ii>i(ii:i(ii2i(ihi"i(iii(iiiz(iii(iii(iii(iii(iiiii(iHi=i(i/iOiO(iii(iii(iyii(iRii(i/iOiO(iii(iii(iii(iii(iii(iiiv(ii iP(iii(iii(iii(iii(iihi(iiiiii(iiiiii(iii(iii(iii(iiti(iiNi(ii"i"(ii0i0(ii,i,(ii&i&(iii(iii(i"ii"(iii(iii(iii(iii(iii(iii(iiui(iii (iii%(iii"(iii(iiii(iii(iii(iii(iii(iii(iii(iii(i!i!i!(i$i$i$(i&i&i&(i)i)i)(i+i+i+(i.i.i.(i0i0i0(iii(i3i3i3(i6i6i6(i8i8i8(i;i;i;(i=i=i=(i@i@i@(iBiBiB(iEiEiE(iGiGiG(iJiJiJ(iii(iMiMiM(iOiOiO(iRiRiR(iTiTiT(iWiWiW(iYiYiY(i\i\i\(i^i^i^(iaiaia(icicic(i i i (ififif(iiiiii(ikikik(ininin(ipipip(isisis(iuiuiu(ixixix(iziziz(i}i}i}(i i i (iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii/(iii(iii(iii(iii(iii(iii(iii(i!i!i!(i$i$i$(i&i&i&(i)i)i)(i+i+i+(i.i.i.(i0i0i0(iii(i3i3i3(i6i6i6(i8i8i8(i;i;i;(i=i=i=(i@i@i@(iBiBiB(iEiEiE(iGiGiG(iJiJiJ(iii(iMiMiM(iOiOiO(iRiRiR(iTiTiT(iWiWiW(iYiYiY(i\i\i\(i^i^i^(iaiaia(icicic(i i i (ififif(iiiiii(ikikik(ininin(ipipip(isisis(iuiuiu(ixixix(iziziz(i}i}i}(i i i (iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iiii(iini(iiji(ii`i(ii:ib(ii\i\(iijij(iicic(iiUiU(ii:i:(iii(iii(iii(iii(iii(iii(iii(iii(iiis(iiiN(iii(iii(iii(iii(iii(iii(i|ii(iii(iii(iii(iii(iiip(iii(iii(iii(iii(ihii(iii(iii(iii(iii(iii(izii(iii(iii(iii(iiip(iiiL(iii(iii(iii(iii(iii(iii(iii(iii(ii_ie(iiiz(iiiz(iiir(iiib(iiWiB(i ii(iii(iii(iii(iii(i`i{i(iipi(iwii(iwii(iii(iii(iii(iii(ini{i(iii(iii(iii(iii(iiiz(i2ii2(iii(iii(iii(iii(iii(iii(ii0i`(ii4i(ii0i(ii)i(iiib(ifii(iii(iiUi(iifi(ii_i(iiRi(izi7i(iipi(iii(iiyi(iihi(i]iGi(i<iiq(i{ihi(iii(iHii(iii(iiip(iii(iii(iii(iii(iii(ii}i{(iii(iii(iii(iii(iii(iiyi^(iii(iii(iii(ikii#(iii>(iii:(iii2(iiii"(iii(iii(iii(iii(iiZi(iiEi(iiEi(ii@i(ii7i(ii%i(iipi(iii(iizi(iiii(iiGi(iii(iii(iii(iii(i|ii|(iTiiT(iii(iii(iii(iii(ifii(iipi(iii(iiyi(iihi(iiGi](iii(iii(iii(iii(iii(iiwie(iii?(iii(iii(iii(iii(iicil(iii(iii(iii(iii(iifi(iii(ii i(ii0i(ii,i(i}i&i(iUii(iii(iii(iii(iii(iii(iii(iii(iii(iii(iiiii(iAiii(iHivi(iCini(i:i_i(i'i@i(iiEi(iiir(iiii(iiib(iipiT(iiLi9(iii`(i.iiW(iTii(iNii(iCii(i.iiW(iii(iii(iii(iii(iii(iiRi-(iiiG(iiyiB(iihi9(iiGi&(iii(iii(i~ii(ilii(iJipi(ijiZi(iioi(izigi(iiiYi(iGi<i(ipii(iii(iii(iii(ili{i(ipii(iii(iii(iii(iii(iii(iii(iii(iiiv(iiif(iiiE(iFii(icii(i\ii(iOii(i6idi(iii(iiiO(iiiI(iii?(iiZi+(iii(iii(iii(iii(ii{i(iiciG(iiciG(ii\iB(iiOi9(ii6i&(i@ii(iii(iii(iii(iii(iii(ii i(ii>i(ii:i(ii2ix(ii"iR(iii(iii(iii(iii(ii~if(iii(iii(iii(iii(iii(iii(iii(iii2(RRRRkR"R_RoR`RrRsRvt staticmethodRRwRxRm(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs`           t_GraphicsContainercBs>eZdZdZdZdZdZdZRS(cCs g|_dS(N(t _contents(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"scCs ||ijS(sBReturn True if obj is currently in the container; False otherwise.(R|(R!tobj((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt __contains__scCs|ii|dS(s)Add the Drawable object to the container.N(R|RW(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRUscCs|ii|dS(s.Remove the Drawable object from the container.N(R|R(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCs1t|i}x|D]}|i|qWdS(s&Remove all objects from the container.N(RNR|R(R!tcontentsRx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytclearscCst}x'|iD]}|i|i|fqW|i|itdjo dG|GHnt}x|D]}|i|dqqW|S(s6Return the contents of the container, sorted by depth.is$Contents of container (depth, item):i(RNR|RWt_depthtsorttreverseR1(R!t contentsPairRxRtpair((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt getContentss       (RRR"R~RURRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR{s      tEventcBsDeZdZdZdZdZdZdZdZRS(s3An event typically triggered by the user interface.cCsCd|_d\|_|_d\|_|_d|_d|_dS(NRgi(ii(ii(t _eventTypeRRt_prevxt_prevyt_keyRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s   cCs|iS(sReturn a text description of the event. Possibilities include: 'mouse click', 'mouse release', 'mouse drag', 'keyboard, 'timer', 'canvas close' (R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetDescriptionscCst|i|iS(sNReturn a Point designating the location of the mouse at the time of the event.(RRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetMouseLocationscCst|i|iS(sRReturn a Point designating the location of the mouse at the start of a mouse drag.(RRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetOldMouseLocationscCs|iS(s:Return a reference to the object that triggered the event.(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt getTrigger scCs|iS(sAReturn a string designating the key pressed for a keyboard event.(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetKeys( RRRR"RRRRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs     t EventHandlercBs eZdZdZdZRS(soA base class for creating new event handlers. The handle method for this base class does not do anything. cCsdS(s\Create a new event handler. Children of this class must call this constructor. N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"scCsdS(sgHandle an event. Child classes must override this method, but do not need to call it. N((R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pythandle s(RRRR"R(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs t_ReleaseHandlercBseZdZdZRS(cCs#||_d|_|iidS(N(t_lockRt_eventtacquire(R!tlock((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR")s  cCs1|idjo||_|iindS(Ntkeyboards mouse clicks canvas close(Rs mouse clicks canvas close(RRRtrelease(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR.s (RRR"R(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR(s t _EventTriggercBs,eZdZdZdZdZRS(cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"5scCsoti}t|}tii||f|i||i|i|tii ||f|i S(sWait for an event to occur. When an event occurs, an Event instance is returned with information about what has happened. ( R R RRDRRURRRRR(R!Rtrh((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytwait8s     cCsZt|tptdnyti||Wntj otdnXdS(s3Register an EventHandler instance with this object.s@Only instance of EventHandler (or child class) can handle eventss2Handler is already handling events for this objectN(RRRRDRR~(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRGs cCsZt|tptdnyti||Wntj otdnXdS(s5Unregister an EventHandler instance from this object.s=Parameter is not an instance of EventHandler (or child class)s9The handler is not currently associated with this object.N(RRRRDRR~(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRPs (RRR"RRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR3s   RcBseZdZdZRS(cCs&tii|||_||_dS(N(R tThreadR"t_handlerR(R!RR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"[s cCs|ii|idS(N(RRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytrun`s(RRR"R(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRZs t_AnimationThreadcBs/eZddZdZdZdZRS(cCsqtii|||_||_||_|iidpd|i|_n||_d|_t |_ dS(Nt.i( R RR"R?t_baset _extensiont startswitht _intervalt_frameRR(R!Rttbaset extensiontinterval((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"ds     cCs9t|_x)|io|iti|iq WdS(N(RRt saveFramet_timetsleepR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRos    cCs t|_dS(N(RR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytstopuscCsL|it|iidd|i}|ii||id7_dS(Nit0i(RRRtrjustRR?RS(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRxs)N(RRRR"RRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRcs  RbcBs eZdZddddedZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZddZddZedZedZdZdZdZdZddZdZdZRS(s A window that can be drawn upon.isGraphics canvasc Csti|ti|t|_|p d}nt|ttfptdnt|ttfptdnt|t ptdnt|t ptdnt|t o ||_ ndyt ||_ WnMtj o}tt |n(t j o}t t |nXtpt|_n"tddddd|f|_||_||_||_||_t|_tii|tdd|_d |_tid ||||i |||ifd S( suCreate a new drawing canvas. A new canvas will be created. w width of drawing area (default 200) h height of drawing area (default 200) bgColor color of the background (default 'White') title window title (default 'Graphics Canvas') autoRefresh whether auto-refresh mode is used (default True) RUswidth must be numericsheight must be numericstitle must be a strings(autoRefresh flag must be a boolean valueiiis create canvasN(R{R"RRt_canvasUpdatedRRRRRtboolRt_backgroundColorR~t _mathModeRRt_widtht_heightt_titleRvt _canvasOpenRDRRURt_mouseCoordinatesRt _animationR)(R!twthtbgColorttitlet autoRefreshtteRe((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"sB     !      cCst|tdjotdnt|to ||_ndyt||_WnMtj o}tt|n(tj o}tt|nX|idS(sSet the background color. The parameter can be either: - a string with the name of the color - an (r,g,b) tuple - an existing Color instance Rhs(Canvas background cannot be transparent.N(RR~RRRRt_canvasChanged(R!tcolorRRe((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRBs cCs|iS(s0Return the background color as a Color instance.(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetBackgroundColorscCsZt|ttfptdn|djotdn||_|idS(sReset the canvas width to w.swidth must be numeric valueiswidth must be positiveN(RRRRR~RR(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRAs   cCs|iS(sReturn the width of the canvas.(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetWidthscCsZt|ttfptdn|djotdn||_|idS(sReset the canvas height to h.sheight must be numeric valueisheight must be positiveN(RRRRR~RR(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR@s   cCs|iS(s Return the height of the canvas.(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt getHeightscCs7t|tptdn||_|idS(s4Set the title for the canvas window to given string.stitle must be a stringN(RRRRR(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRCs cCs|iS(sReturn the title of the window.(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetTitlescCs|iot}xZtiD]O}|d|jp#|tii|dtjo|i|dqqWx-|D]%}t}d|_|i |qwWti d|fti i |t |_ndS(swClose the canvas window (if not already closed). The window can be reopened with a subsequent call to open(). iis canvas closes close canvasN(RRRDRRR&RURRRR)RRR(R!twaitingRte((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytcloses   4  c Cs|ipt|_tii||ip;tid||i|i|i |i |i |i fntid|f|i o|i tqndS(ssOpens a graphic window (if not already open). The window can be closed with a subsequent call to close(). s create canvass open canvasN(RRRDRRUR?R)RRRRRvRtrefresh(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRj s   ; cCst|tptdn||ijotdnti||dt|jotdny |i WntdnXt i i |ot i |i|nt |gt i |<|idS(s&Add the Drawable object to the canvas.s.Only Drawable objects can be added to a CanvassObject already on the CanvasRsKDrawable instance not properly initialized (was parent constructor called?)s3Child class of Drawable must provide a _draw methodN(RtDrawableRR|R~R{RUtvarst StandardErrort_drawRDRRTRR(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRUs cCs>||ijotdnti|||idS(s+Remove the drawable object from the canvas.s"Object not currently on the CanvasN(R|R~R{RR(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR/scCst|t pt|t otdn|i|ijp|i|ijotdnt|i|i|i}t|i |i|i}| |i}|i||i}t |dd|||f|_ |i dS(sSet the coordinates for the lower-left corner and upper-right corners of the canvas. lowerLeft and upperRight are Point instances storing the coordinates of the corners. s0lowerLeft and upperRight must be Point instancessKLower left and upper right corners must have different x and y coordinates.iN( RRRRRR~RRRRRR(R!t lowerLeftt upperRighttxScaletyScaletxTranstyTrans((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt setViewWindow6s"2&'!c Cs|p't|id|id}n|it|dd||id||i|id||if|_|idS(Ng@ii(RRRRRRRR(R!Rtcenter((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytzoomIs 'CcCs|p't|id|id}ntdddd|i|if}ti |d}tti|ti |ti | ti|ddf}|i |||i |_ |i dS(Ng@iigf@g( RRRRRRRRRRRRR(R!RRt translationtrot((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytrotateRs'*(cCsMt|tptdn|o|i o|in||_dS(sChange the auto-refresh mode. When True (the default), every change to the canvas or to an object drawn upon the canvas will be immediately rendered to the screen. When False, all changes are recorded internally, yet not shown on the screen until the next subsequent call to the refresh() method of this canvas. This allows multiple changes to be buffered and rendered all at once. s!autoRefresh flag should be a boolN(RRRRvR(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytsetAutoRefresh^s cCs|i|dtttdS(s Forces all internal changes to be rendered to the screen. This method is only necessary when the auto-refresh property of the canvas has previously been turned off. If force is True then the entire window is redrawn regardless of need. N(RwRR(R!tforce((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRpsc Cs tiiytid||f|||ft_|pPtid||i|i|i|ifxX|i D]}|i qwWn7x3|D]+}tid|f|ddi qWtid|ft Wnt djo dGHqnXtii dS( Ns begin refreshs update canvass set chainiiscomplete refreshisException thrown in refresh(RDR RR)R=RRRRRRRR1R(R!Rt needsUpdatingRyRzR{RxRq((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRwzs$ +   c Cs,t|tptdnd|jotdn|iddi}tp!|djotdqn|djotdnt|id |i d }|i t |id t |i d |i |i |i|i d }x4|iD])}|i|jo|i}q$q$W|i|d|i||it|djo |}n#tid\}}ti|tid||ft|djo6ti|id}|i|ti|n|i||idS(sSave a picture of the current canvas to a file. The filename extension must be a supported file type: .eps, ps If the Python Imaging Library is installed then addition supported file types are: .gif, .jpg, .jpeg, .png sfilename must be a stringRs,filename extension should indicate file typeitepstpssUnsupported file typetgiftjpgtjpegtpngiiitEPStPSs.epss save to fileR<N(RR(RRRRR(RRRR(RR( RRRR~tsplitRiRgt RectangleRRtmoveRt setFillColorRtsetBorderColorR|tgetDepthtsetDepthRURRt _tempfiletmkstempt_osRRDR)RiRjRktsaveR( R!Rtextt backgroundtmaxDepthtot epsFilenametfdRu((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRSsB    #0         cCs|iS(s+Return the current coordinate of the mouse.(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetMouseCoordinatesscCs%t|_|io|indS(N(RRRvR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs  cCs|iotdn|oSt|t o!t|t otdn|djotdqtnt|||||_|o|iin|ii dS(sBegin an animation that will save the canvas as a sequence of image files. Each frame of the animation will be saved with a filename staring with baseFilename followed by the frame number and then the given extension. for saveToFile for the supported file types. s5An animation is already running, cannot start anothersTime interval must be numericisTime interval must be positiveN( RRRRRRR~RRR(R!t baseFilenameRR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytbeginAnimations " cCs+|iptdn|iidS(s$Save a frame to a running animation.s%An animation is not currently runningN(RRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt createFrames cCs+|iptdn|iidS(sStop the running animation.s%An animation is not currently runningN(RRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt endAnimations N(RRRRRR"RBRRARR@RRCRRRjRURRRRRRRRwRSRRRRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRb}s46              6    RcBseZdZddZdZdZdZdZdZ ddZ dd Z dd Z d Z d Zd ZdZdZdZdZdZdZdZeeedZRS(s1An object that can be drawn to a graphics canvas.cCsti||o-t|tptdn||_n t|_t|_dti g|_ t |i i dpst |i i}x[|D]O}t |i |}y,|i|djo|i||nWqqXqWndS( sCreate a Drawable instance. referencePoint local reference point for scaling, rotating and flipping (default Point(0,0) ) s(reference point must be a Point instancei2t_noAutomaticCallt__new__R"RN(s__new__s__init__s_draw(RR"RRRt _referenceRRt _ourRandomtrandomRRt __class__RTREt__call__t_replaceMethod(R!t referenceREtntv((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s&     cs&fd}t|i||dS(Ncs |||}|i|S(N(Ry(R!targstkwRl(tcs1graphicsWrapper(scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytwraps (tsetattrR(R!tnameRR ((RscC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCst|ttfptdnt|ttfptdntdddd||f|i|_|itttdS(sMove the object dx units along X-axis and dy units along Y-axis. For the default coordinate system, positive dx is rightward and negative is leftward; positive dy is downard and negative is upward. sdx must be numericsdy must be numericg?gN( RRRRRRRyRR(R!RR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs (cCst|ttfptdnt|ttfptdn|i}|i||i||i|it t t dS(s7Move the object to align its reference point with (x,y)sx must be numericsy must be numericN( RRRRtgetReferencePointRRRRyRR(R!RotytcurRef((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytmoveTo#s $cCst|ttfptdnti |d}|i|i}td|i }tti |ti |ti | ti |ddf}|||i |i |_ |itttdS(snRotate the object around its current reference point. angle number of degrees of clockwise rotation s#angle must be specified numericallygf@g?gN(g?ggg?(RRRRRRt_localToGlobalRRR&RRRRRyRR(R!RRttransR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR-s(cCst|ttfp tdn|djo tdn|i|i}td|i}t|dd|ddf}|||i |i |_ |i t t t dS(sScale the object relative to its current reference point. factor scale is multiplied by this number (must be positive) s(scaling factor must be a positive numberig?gN(g?ggg?(RRRRR~RRRR&RRRyRR(R!RRRtsca((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR=s   ic Cs4t|ttf pt|ttf o tdn|djp |djo tdn|i|i}td|i}tt i |t i |t i | t i |ddf}|i }t|dd|ddf}|||||i |i |_ |itttdS(sStretch the shape in mutltiple direction. By default the x-axis is scaled by a factor of xFactor and the y-axis is scaled by a factor of yFactor. The optional parameter rotates the directions that the streching is performed along. s(stretch factor must be a positive numberig?gN(g?ggg?(RRRRR~RRRR&RRRRRRyRR( R!txFactortyFactorRRRRtrotinvR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytstretchNs.  ( &cCst|ttfptdnti|d}|i|i}td|i }tti |ti |ti | t |ddf}|i }td}|||||i |i|_|itttdS( sFlip the object reflected about its current reference point. By default the flip is a left-to-right flip with a vertical axis of symmetry. angle a clockwise rotation of the axis of symmetry away from vertical sangle must be numericgf@g?ggN(g?ggg?(gggg?gg(RRRRRRRRRR&RRt_cosRRRyRR(R!RRRRRtinvert((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytflipes%  &cCs0t|ttfptdnt|ttfptdnti|d}|i|i}td|i }tti |ti |ti | ti |ddf}|i }td| ddddf}|||||i |i |_ |itttdS(syShear the object relative to its current reference point. By default, points with the same y-coordinate as the reference point are left unchanged. A point d units above the reference point is shifted d * shear units to the right. The optional angle parameter rotates the axis that the shearing occurs along. angle clockwise angle for shear sshear factor must be numericsangle must be numericgf@g?gN(g?ggg?(RRRRRRRRRR&RRRRRyRR(R!tshearRRRRRtsh((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRzs ( &cCs|i|iS(szReturn a copy of the current reference point. Note that mutating that copy has no effect on the Drawable object. (RR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR scCst|ttfptdnt|ttfptdn|i|i}t|i||i|}|i ||_dS(stMove the local reference point relative to its current position. Note that the object is not moved at all. sdx must be numericsdy must be numericN( RRRRRRRRRt_globalToLocal(R!RRR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytadjustReferences#cCsJt|ttfptdn||id<|itttdS(ssSet the depth of the object. Objects with a higher depth will be rendered behind those with lower depths. sdepth must be numericiN(RRRRRRyRR(R!R{((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs cCs |idS(sReturn the depth of the object.i(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCs ti|S(sReturn a duplicate of the drawable object. Note that the duplicate is not automatically added to any canvases or layers, even if original is currently so. (t_copytdeepcopy(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytclonescCs0t|tptdn|ii|S(Ns"parameter must be a Point instance(RRRRRu(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCs6t|tptdn|iii|S(Ns"parameter must be a Point instance(RRRRRRu(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCstid|fdS(Ns begin draw(RDR)(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt _beginDrawscCstid|fdS(Ns complete draw(RDR)(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt _completeDrawscCs*tdjo dG|GHntddS(sLCause the object to be drawn (typically, the method is not called directly).iswithin Drawable._draw for self=s2_draw() method must be implemented for each shape.N(R1tNotImplementedError(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs  cCs%toti||||ndS(sDesignate that some trait of this object has been mutated. As a result, all of its rendered images may need to be updated. N(RDR}(R!RyRzR{((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRysN(RRRRR"RRRRRRRRR RRRR RRR!R"RRRy(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs*               tLayercBs;eZdZdZdZdZdZdZRS(sA composite that represents a group of shapes as a single drawable object. Objects are placed onto the layer relative to the coordinate system of the layer itself. The layer can then be placed onto a canvas (or even onto another layer). cCsti|ti|dS(sConstruct a new Layer instance. The layer is initially empty. The reference point of that layer is initially the origin in its own coordinate system, (0,0). N(RR"R{(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCstdjodG|GdG|GHnt|tptdn||ijotdndt|jotdny |iWntdnXt i |||i d S( s%Add the Drawable object to the layer.isCall to Layer.add with self=s drawable=s2parameter must be an instance of a Drawable objects"The object is already on the LayerRsBDrawable not properly initialized (was parent constructor called?)s'Drawable class must have a _draw methodN( R1RRRR|R~RRRR{RURy(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRUs  cCs>||ijotdnti|||idS(szRemove the Drawable object from the layer. A ValueError is raised if the drawable is not currently in the layer. s!object not currently on the LayerN(R|R~R{RRy(R!Rx((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCs9|ix|iD]}|iqW|idS(N(R!RRR"(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR s   (RRRR"RRURR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR$s    tShapecBsGeZdZddZdZdZdZdZdZ RS(s%A drawable objects that has a border.cCsT|o!t|t otdnti||td|_d|_dS(sConstruct a Shape instance. reference the initial placement of the shape's reference point. (default Point(0,0) ) s(reference point must be a Point instancetBlackiN(RRRRR"Rt _borderColort _borderWidth(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s cCs|i}t|to ||_ndyt||_WnMtj o}tt|n(tj o}tt|nX|ittt|i|j oF|ii |t|t  p||i j o|i |qndS(s Set the border color to a copy of the indicated color. The parameter can be either: - a string with the name of the color - an (r,g,b) tuple - an existing Color instance N( R'RRRRR~RyRRRwt FillableShapet _fillColorRx(R!RtoldRRe((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s  !cCs|iS(s(Return the color of the object's border.(R'(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetBorderColor=scCsct|ttfptdn|djotdn||_|itttdS(s= Set the width of the border to the indicated width. s(Border width must be non-negative numberis*A shape's border width cannot be negative.N( RRRRR~R(RyRR(R!twidth((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytsetBorderWidthAs   cCs|iS(sReturn the width of the border.(R((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetBorderWidthLscCs#|i|9_ti||dS(N(R(RR(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRPsN( RRRRR"RR,R.R/R(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR%s   R)cBs,eZdZddZdZdZRS(s2A shape that can be filled with an interior color.cCsK|o!t|t otdnti||td|_dS(sConstruct a new FillableShape instance. The interior color defaults to 'Transparent'. reference the initial placement of the shape's reference point. (default Point(0,0) ) s(reference point must be a Point instancet TransparentN(RRRR%R"RR*(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"WscCs|i}t|to ||_ndyt||_WnMtj o}tt|n(tj o}tt|nX|ittt|i|j o5|ii ||i |j o|i |qndS(sSet the interior color of the shape to the color. The parameter can be either: - a string with the name of the color - an (r,g,b) tuple - an existing Color instance N( R*RRRRR~RyRRRwR'Rx(R!RR+RRe((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRds  cCs|iS(s)Return the color of the shape's interior.(R*(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt getFillColorsN(RRRRR"RR1(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR)Ts tCirclecBsAeZdZdddZdZdZdZdZRS(s'A circle that can be drawn to a canvas.i cCst|ttfptdn|djotdn|o!t|t otdnti||p t}nt|dd||i |i f|_ dS(sConstruct a new instance of Circle. radius the circle's radius (default 10) centerPt a Point representing the placement of the circle's center (default Point(0,0) ) The reference point for a circle is originally its center. sRadius must be a numberis%The circle's radius must be positive.s0The circle's center must be specified as a PointgN( RRRRR~RR)R"RRRR(R!tradiustcenterPt((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s    cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCst|ttfptdn|djotdnt||i}|it|dd|ddf|_|it t t dS(s"Set the radius of the circle to r.sRadius must be a numberis%The circle's radius must be positive.gN( RRRRR~t getRadiusRRRyRR(R!trR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt setRadiuss (cCs-ti|iidd|iiddS(s Return the radius of the circle.iii(RRRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR5scCs+|itid|f|idS(Ns draw circle(R!RDR)R"(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs N( RRRRR"RR7R5R(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR2s   tEllipsecBsVeZdZddd dZdZdZdZdZdZ dZ RS( s(A ellipse that can be drawn to a canvas.i cCst|ttf pt|ttf otdn|djp |djotdn|o!t|t otdnti||p t}ntd|ddd||i |i f|_ dS(s5Construct a new instance of Circle. width the ellipse's width (default 10) height the ellipse's height (default 10) centerPt a Point representing the placement of the circle's center (default Point(0,0) ) The reference point for a ellipse is originally its center. s Width and height must be numbersis0The ellipse's width and height must be positive.s1The ellipse's center must be specified as a Pointg?gN( RRRRR~RR)R"RRRR(R!R-theightR4((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s .  cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCst|ttfptdn|djotdnt||i}|it|dddddf|_|it t t dS(s"Set the width of the ellipse to w.sWidth must be a numberis%The ellipse's width must be positive.gg?N( RRRRR~RRRRyRR(R!RR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRAs (cCs1dti|iidd|iiddS(s Return the width of the ellipse.ii(RRRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCst|ttfptdn|djotdnt||i}|itddd|ddf|_|it t t dS(s#Set the height of the ellipse to h.sWidth must be a numberis%The ellipse's width must be positive.g?gN( RRRRR~RRRRyRR(R!RR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR@s (cCs1dti|iidd|iiddS(s!Return the height of the ellipse.iii(RRRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCs+|itid|f|idS(Ns draw circle(R!RDR)R"(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs N( RRRRR"RRARR@RR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR8s   RcBsVeZdZddd dZdZdZdZdZdZ d Z RS( s,A rectangle that can be drawn to the canvas.ii cCst|ttfptdn|djotdnt|ttfptdn|djotdn|o!t|t otdnti||ptdd}nt|dd||i |i f|_ dS( sI Construct a new instance of a Rectangle. The reference point for a rectangle is its center. w the width of the rectangle (default 20) h the height of the rectangle (default 10) centerPt a Point representing the placement of the rectangle's center (default Point(0,0) ) sWidth must be a numberisThe width must be positive.sHeight must be a numbersThe height must be positive.s#center must be specified as a PointgN( RRRRR~RR)R"RRRR(R!RRR4((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s    cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCs-ti|iidd|iiddS(s"Return the width of the rectangle.ii(RRRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCs-ti|iidd|iiddS(s#Return the height of the rectangle.iii(RRRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRscCst|ttfptdn|djotdnt||i}|i|i}td|i }t|dddddf}|||i |i |_ |i t ttdS(s$Set the width of the rectangle to w.sWidth must be a positive numberis&The rectangle's width must be positiveg?gN(g?ggg?(RRRRR~RRRRR&RRRyRR(R!RRRRR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRA s cCst|ttfptdn|djotdnt||i}|i|i}td|i }tddd|ddf}|||i |i |_ |i t ttdS(s%Set the height of the rectangle to h.s Height must be a positive numberis'The rectangle's height must be positiveg?gN(g?ggg?(RRRRR~RRRRR&RRRyRR(R!RRRRR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR@.s cCs+|itid|f|idS(Nsdraw rectangle(R!RDR)R"(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR<s N( RRRRR"RRRRAR@R(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRs     tSquarecBsJeZdZdddZdZdZdZdZdZ RS( s)A square that can be drawn to the canvas.i cCst|ttfptdn|djotdn|o!t|t otdnti||||dS(s  Construct a new Square instance. The reference point for a square is its center. size the dimension of the square (default 10) centerPt a Point representing the placement of the rectangle's center (defaults Point(0,0) ) ssize must be a numberisThe size must be positive.s#center must be specified as a PointN(RRRRR~RRR"(R!RrR4((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"Es  cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRXscCs |iS(s*Return the length of a side of the square.(R(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetSize\scCsgt|ttfptdn|djotdnti||ti||dS(s,Set the width and height of the square to s.ssize must be a numberisThe size must be positive.N(RRRRR~RRAR@(R!ts((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytsetSize`s  cCsTt|ttfptdn|djotdn|i|dS(s,Set the width and height of the square to w.swidth must be a positive numberis#The square's width must be positiveN(RRRRR~R=(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRAjs  cCsTt|ttfptdn|djotdn|i|dS(s,Set the width and height of the square to h.s height must be a positive numberis$The square's height must be positiveN(RRRRR~R=(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR@rs  N( RRRRR"RR;R=RAR@(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR:Cs   tPathcBsqeZdZdZdZddZddZdZdZdZ dd Z d Z d Z RS( s+ A path that can be drawn to a canvas. c Gsti|t|djo"yt|d}WqBqBXnx.|D]&}t|tptdqIqIWt||_t|idjo.|i |idi |idi ndS(s Construct a new instance of a Path. The path is described as a series of points that are connected in order. These points can be initialized by sending each individual Point as a separate parameter, or by sending a single parameter containing a sequence of Points. If no parameters are sent, the path initially has zero points. The reference point for a path is initially aligned with the first point of the path. iis non-Point specified as parameterN( R%R"RVRRRRRNt_pointsRRR(R!tpointsR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"~s cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRsicCst|tptdn|djo|ii||n|ii|t|idjo"t|i|i|_ n|i t t t dS(sAdd a new point to the Path. point a Point instance index designates where on the path the new point is placed (at the end, by default) s"parameter must be a Point instanceiiN( RRRR?tinsertRWRVRRRRyRR(R!RRR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytaddPoints "cCsat|tptdny|ii|WntdnX|itttdS(sMRemove the Point at the given index. By default, deletes the last point.sindex must be an integersindex out of rangeN( RRRR?tpopt IndexErrorRyRR(R!RR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt deletePointscCs#t|_|itttdS(s6Remove all points, setting this back to an empty Path.N(RNR?RyRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt clearPointss cCs t|iS(s$Return the current number of points.(RVR?(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetNumberOfPointsscCs`t|tptdny|i|}WntdnXt|i|iS(ssReturn a copy of the Point at the given index. Subsequently mutating that copy has no effect on the Path. sindex must be an integersindex out of range(RRRR?RDRRR(R!RRR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pytgetPointscCs~t|tptdnt|tptdny||i|zs       tPolygoncBs)eZdZdZdZdZRS(s(A polygon that can be drawn to a canvas.cGsOti|yti||Wn'tj o}tt|nXdS(s!Construct a new Polygon instance. The polygon is described as a series of points that are connected in order. The last point is automatically connected back to the first to close the polygon. These points can be initialized by sending each individual Point as a separate parameter, or by sending a single parameter containing a sequence of Points. If no parameters are sent, the polygon initially has zero points. The reference point for a polygon is initially aligned with the first point of the polygon. N(R)R"R>RR(R!R@R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR"s  cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR scCs+|itid|f|idS(Ns draw polygon(R!RDR)R"(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR s (RRRR"RR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRJs  tSplinecBsqeZdZdZdZddZddZdZdZdZ dd Z d Z d Z RS( s2 A curved path that can be drawn to a canvas. c Gsti|t|djo"yt|d}WqBqBXnx.|D]&}t|tptdqIqIWt||_t|idjo.|i |idi |idi ndS(s Construct a new instance of a Spline. The spline is described as a series of points that are connected in order with curves. These points can be initialized by sending each individual Point as a separate parameter, or by sending a single parameter containing a sequence of Points. If no parameters are sent, the path initially has zero points. The reference point for a spline is initially aligned with the first point of the spline. iis non-Point specified as parameterN( R%R"RVRRRRRNR?RRR(R!R@R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR" s cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR. sicCst|tptdn|djo|ii||n|ii|t|idjo"t|i|i|_ n|i t t t dS(sAdd a new point to the Spline. point a Point instance index designates where on the path the new point is placed (at the end, by default) s"parameter must be a Point instanceiiN( RRRR?RARWRVRRRRyRR(R!RRR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRB1 s "cCsat|tptdny|ii|WntdnX|itttdS(sMRemove the Point at the given index. By default, deletes the last point.sindex must be an integersindex out of rangeN( RRRR?RCRDRyRR(R!RR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyREB scCs#t|_|itttdS(s8Remove all points, setting this back to an empty Spline.N(RNR?RyRR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRFN s cCs t|iS(s$Return the current number of points.(RVR?(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRGS scCs`t|tptdny|i|}WntdnXt|i|iS(suReturn a copy of the Point at the given index. Subsequently mutating that copy has no effect on the Spline. sindex must be an integersindex out of range(RRRR?RDRRR(R!RRR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRHW scCs~t|tptdnt|tptdny||i||i\}}|i||i|i||idS(N(RZRARQR@(R!RR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt_resizef scCsltdjo dGHn|idjoti||idn(|idjoti||indS(s0Highlight the button when the button is clicked.isButton self handlers mouse clickis mouse releaseN(R1RRR.R\(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRk s   cCs2|iti|ti||idS(N(R!RRROR"(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRt s   cCs||_ti||dS(s= Set the width of the border to the indicated width. N(R\RR.(R!R-((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR.z s cCsti|||idS(sJChanges the button's text to message and automatically resizes the button.N(RORTR](R!R.((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRT scCsti|||idS(sDChanges the button's text size and automatically resizes the button.N(RORXR](R!RS((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRX sN( RRRRR"RR]RRR.RTRX(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR[O s     tTextBoxcBs;eZdZddddZdZdZdZRS(sWidget for text entry.idi2cCsWti|dd|ti|||||idti||i|dS(sConstruct a box to enter text into. width the width of the box height the height of the box centerPt the location of the boxes center Rgi RUN(ROR"RRRR(R!R-R9R4((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR" s   cCsdS(N((R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR scCs2|iti|ti||idS(N(R!RRROR"(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR s   cCsc|idjoO|idjo|i|id q_|i|i|indS(sFWhen the text box is in focus append any keypress to the display text.RsiN(RRRTRU(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR sN(RRRRR"RRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR^ s   tTimercBs;eZedZedZdZdZdZRS(cCs8ti|||_||_t|_t|_dS(N(RR"t_delayt_repeatRRRNR(R!tdelaytrepeat((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR" s     cCsE|i p|o/t|_t||i|_|iindS(N(RRt _TimerThreadR`t_threadR(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR s cCs t|_dS(N(RR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR scCsTt|tptdn||ijo|ii|n tddS(Ns4Only child classes of EventHandler can handle eventss*Handler is already associated to the shape(RRRRRWR~(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR s cCs4||ijo|ii|n tddS(Ns7Cannot remove hander from shape it is not associated to(RRR~(R!R((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR s(RRRR"RRRR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR_ s     RdcBseZdZdZRS(cCs&tii|||_||_dS(N(R RR"t_timerR`(R!ttimerRb((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR" s cCsti|i|iio!|iio|iitn|iio:x7|iiD]%}t }d|_ |i |qXWndS(NRg( RRR`RfRaRRRRRRR(R!RR((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR s    (RRR"R(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRd s tMonitorcBs)eZdZdZdZdZRS(s)Monitor class for thread synchronization.cCs ti|_|iidS(sCreate a new monitor instance.N(R R RR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR" scCs|iidS(s6Wait for the monitor to be released by another thread.N(RR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR scCs%|iio|iindS(s0Release a thread that is waiting on the monitor.N(RtlockedR(R!((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR s(RRRR"RR(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRh s  t_TkGraphicsManagercBseZdZdZRS(cCsStdjo dG|GHn|ddiii|i|i|ii|dS(NisRemoving underlying objecti(R1R?ReRt_objectRC(R!Rq((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRF s  %cCs:x!|iD]}|iiiq Wt|_dadS(N(RR?RIRJRRRG(R!Rt((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyR* s   (RRRFR*(((scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyRj s R>cBsGeZdZdZdZdZdZdZdZRS(c s2tdjo dGHn|_ti_iidiiii|tiid|d|dt |_ i i dt dti iid d fd }i id |i id |i id |i id|i id|i idS(NisCreating _RenderedCanvastWM_DELETE_WINDOWR-R9Rtexpandtsideics i|S((t _handleEvent(R(R!(scC:\Users\Natasha\web-pages\mine\English\Teaching\CSI32-Spring2010\materials\Lecture9\cs1graphics.pyt ss