^c@sdZddlTddlZdZdZdZdZdZd Zd Z d Z d Z d Z dZ dZdddYZdefdYZdddYZdddYZdS(szStrip viewer and related widgets. The classes in this file implement the StripViewer shown in the top two thirds of the main Pynche window. It consists of three StripWidgets which display the variations in red, green, and blue respectively of the currently selected r/g/b color value. Each StripWidget shows the color variations that are reachable by varying an axis of the currently selected color. So for example, if the color is (R,G,B)=(127,163,196) then the Red variations show colors from (0,163,196) to (255,163,196), the Green variations show colors from (127,0,196) to (127,255,196), and the Blue variations show colors from (127,163,0) to (127,163,255). The selected color is always visible in all three StripWidgets, and in fact each StripWidget highlights the selected color, and has an arrow pointing to the selected chip, which includes the value along that particular axis. Clicking on any chip in any StripWidget selects that color, and updates all arrows and other windows. By toggling on Update while dragging, Pynche will select the color under the cursor while you drag it, but be forewarned that this can be slow. i(t*Nsproc setcolor {canv colors} { set i 1 foreach c $colors { $canv itemconfigure $i -fill $c -outline $c incr i } } iiit cCsXd|d}d}g}x7|dkrS|jt|||}|d}qW|S(Ngo@igi(tappendtint(tnumchipststeptstarttseq((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytconstant4s cCs&t|}td|g|||S(N(RtmaptNone(RtredtgreentblueR((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytconstant_red_generator?s cCs&t|}td||g||S(N(RR R (RR R R R((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytconstant_green_generatorDs cCs&t|}td|||g|S(N(RR R (RR R R R((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytconstant_blue_generatorIs cCs-t|}td||g||g|S(N(RR R (RR R R R((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytconstant_cyan_generatorNs cCs-t|}td|g|||g|S(N(RR R (RR R R R((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytconstant_magenta_generatorSs cCs-t|}td|g||g||S(N(RR R (RR R R R((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytconstant_yellow_generatorXs t LeftArrowcBsSeZdZdZdZdZd ZdZdZdZ dZ d Z RS( iii it leftarrowcCs5||_|j|\|_|_|j|dS(N(t_canvast_createt_LeftArrow__arrowt_LeftArrow__texttmove_to(tselftcanvastx((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt__init__es c Cs|jj||j|j||j||j|jddddd|j}|jj||jd|j|jd|jdd}||fS( Ntarrowtfirsttwidthg@ttagsi ttextt128(Rt create_linet _ARROWHEIGHTt_YOFFSETt _ARROWWIDTHt_TAGt create_textt _TEXTYOFFSET(RRRR#((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyRjs      cCs)|jj|j}|s!t|dS(Ni(RtcoordsR)tAssertionError(RR,((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt_xys cCs-||j}|jj|j|ddS(Ni(R.RtmoveR)(RRtdeltax((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR~scCs|jj|jd|dS(NR#(Rt itemconfigureR(RR#((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytset_texts(R( t__name__t __module__R(R&R'R+R)RRR.RR2(((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR^s    t RightArrowcBs eZdZdZdZRS(t rightarrowc Cs|jj||j||j|j||j|j|jddddd|j}|jj||jd|j|jdtdd d|j}||fS( NRtlastR!g@R"itjustifyR#R$( RR%R'R(R&R)R*R+tRIGHT(RRRR#((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyRs     cCs0|jj|j}|s!t|d|jS(Ni(RR,R)R-R((RR,((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR.s (R6(R3R4R)RR.(((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR5s t StripWidgetc BsneZdZdZdZd eeed d dd d d ZdZd dZdZ dZ d Z RS( i2i i(tc  Cs||_||_||_|jdks0t| |_| |_d|_||_||d} |d} t |d| d| } |_ | j | j d|j | j d|j | j d |j | jjtg}|_d}d }d}xht|jD]W}d }| j||||||d |d|d|||d}|j|q W| jd||dd|dt|_|jd}t| ||_|jt|d}t| ||_dS(Niiii+R!theightsss itchiptgreytfilltoutlineR"iiR#tanchor(iii(R=(t_StripWidget__generatort_StripWidget__axist_StripWidget__numchipsR-t_StripWidget__uwdt_StripWidget__hexpR t_StripWidget__lastchipt_StripWidget__sbtCanvast_StripWidget__canvastpacktbindt_StripWidget__select_chipttktevaltTCLPROCt_StripWidget__chipstrangetcreate_rectangleRR*tWt_StripWidget__labelt_StripWidget__arrow_xRt_StripWidget__leftarrowtlenR5t_StripWidget__rightarrow(Rt switchboardtmastert chipwidtht chipheightRt generatortaxistlabeltuwdvarthexvart canvaswidtht canvasheightRtchipsRtyR"tctcolortchipx((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyRsL             cCs@|jj|d}|s"t|\}}}}||dS(Nig@(RJR,R-(RtchipnumR,tx0ty0tx1ty1((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt __arrow_xs c Cs|j}|j}|j}|j||||}|rd|dkoW|jknr|j|dd}tj|\}}} t|j } | t ks|j j r|j j||| q|j|d||| fndS(Nii(RRfRJtfind_overlappingRDRQtColorDBtrrggbb_to_tripletRttypetBTNUPREtgetRHt update_viewst_StripWidget__trackarrow( RteventRRfRR=RhR R R tetype((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt __select_chips   )cCsP|jdk rC|jj|jd}|jj|jd|n||_||j}|jjrwt|}n t |}|dkr|j j ||j j |j |d|jj dn=|jj ||jj |j |d|j j dtj|}|dkr0d}nd}|jj|d|dS(NR?R@iiitwhitetblack(RGR RJtitemcgetR1RCRFRuthextreprRWR2RRVRYRqttriplet_to_brightness(RR=trgbtupleRht coloraxisR#t brightnessR@((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt __trackarrows(      cCs|jstd}d}g}|_|jj}x|j|j|||D]h}tj|} |j| |\} } } | |kr| |kr| |kr|}n|d}qPWt j |} |j d|jj | f|j ||||fdS(Niissetcolor %s {%s}(RBR-RQRJRNRDRqttriplet_to_rrggbbRtSPACEtjoinROt_wRw(RR R R tiR=ReRNtttrrggbbttredttgreenttbluetcolors((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytupdate_yourself#s  " $ cCs&|jj|jd|||_dS(NR#(RJR1RURB(RR`R^((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pytset7sN( R3R4t _CHIPHEIGHTt _CHIPWIDTHt _NUMCHIPSR RRVRMRwRR(((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR:s" ;   " t StripViewercBsJeZddZdZddZddZddZdZRS(c Cs||_|j}t|dtdd}|jddddddd d t}|_|j|jd dt}|_ |j|jd dt|}|j d t dt t ||dtddddd|d||_t ||dtddddd|d||_t ||dtddddd|d||_t|}|j d t dt |jddd|jdddd} t|ddd|j} | jddddddd td| t|ddd |} | jddddd tt|dd!d |d|j} | jddddd tt|dd"d|j} | jddddddd td| dS(#Ntrelieft borderwidthitrowtcolumnit columnspanitstickytNSEWt UPWHILEDRAGtHEXSTRIPtexpandR?R^R_R`sRed VariationsRaRbsGreen VariationssBlue VariationstweightiiR#tBlacktcommandtrowspantpadxsUpdate while draggingtvariablet HexadecimaltWhite(t_StripViewer__sbtoptiondbtFrametRAISEDtgridt BooleanVart_StripViewer__uwdvarRRut_StripViewer__hexpvarRKtYEStBOTHR:Rt_StripViewer__redsRt_StripViewer__greensRt_StripViewer__bluestcolumnconfiguretButtont_StripViewer__toblackRTt Checkbuttont_StripViewer__togglehext_StripViewer__towhitetE(RRZR[Rtframetuwdthexptframe1tframe2Rtblackbtntuwdbtnthexbtntwhitebtn((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR=s^  "       (      cCsF|jj||||jj||||jj|||dS(N(RRRR(RR R R ((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyRscCs/|jj\}}}|j|||dS(N(Rt current_rgbR(RRxR R R ((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt __togglehexscCs|jjddddS(Ni(RRv(RRx((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt __toblackscCs|jjddddS(Ni(RRv(RRx((s8/usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt __towhitescCs*|jj|d<|jj|ds$        (