B 0£ÌÀYã@s*dZddlTddlZdZGdd„dƒZdS)a(TextViewer class. The TextViewer allows you to see how the selected color would affect various characteristics of a Tk text widget. This is an output viewer only. In the top part of the window is a standard text widget with some sample text in it. You are free to edit this text in any way you want (BAW: allow you to change font characteristics). If you want changes in other viewers to update text characteristics, turn on Track color changes. To select which characteristic tracks the change, select one of the radio buttons in the window below. Text foreground and background affect the text in the window above. The Selection is what you see when you click the middle button and drag it through some text. The Insertion is the insertion cursor in the text window (which only has a background). é)Ú*NzText Window...c@sbeZdZddd„Zddd„Zddd„Zddd „Zdd d „Zdd d „Zddd„Z dd„Z dd„Z dS)Ú TextViewerNcCs||_| ¡}t|dd}|_| d|j¡| d¡| d¡| d|j ¡| d|j ¡| d|j¡| d|j¡t |t |  d d ¡|  d d ¡d dd|_ |  d¡}|r¼|j j|d|  d¡}|rØ|j j|d|  d¡}|rô|j j|d|j  ¡|j  d|  dd¡¡|  d¡}|r2|j  t|¡y(|  ddtf¡\} } |j  t| | ¡Wntk rpYnX|j  ¡tƒ|_|j |  dd¡¡tƒ|_|j |  dd¡¡t|d|jt|jd |_ |j jt!t"d!t#|ƒ} |_$|  ¡g|_%d"} x>d#D]6} t&| | d$}|j'| dt(d%|j% )|¡| d&7} qWd&}xzzzÚTEXTBGZblackÚTEXTFGZwhiteé#é)ÚreliefÚ backgroundÚ foregroundÚwidthZheightÚTEXT_SFG)ÚselectforegroundÚTEXT_SBG)ÚselectbackgroundÚTEXT_IBG)ÚinsertbackgroundgÚTEXTzÄInsert some stuff here and play with the buttons below to see how the colors interact in textual displays. See how the selection can also be affected by tickling the buttons and choosing a color.ÚTEXTINSÚTEXTSELg@ÚTRACKPrÚWHICHzTrack color changes)ÚtextÚvariablerÚcommand)ZfillÚexpandé)zText:z Selection:z Insertion:)r)ÚrowÚcolumnZstickyé)Z ForegroundZ Background)rr)rr)réér )rÚvaluer)-Ú_TextViewer__sbÚoptiondbZToplevelÚ_TextViewer__rootZprotocolÚwithdrawÚtitleZiconnameZbindÚ_TextViewer__quitZTextZSUNKENÚgetÚ_TextViewer__textÚ configureZpackÚinsertZmark_setÚINSERTZENDZtag_addÚSELÚ ValueErrorZ focus_setZ BooleanVarÚ_TextViewer__trackpÚsetZIntVarÚ_TextViewer__whichZ CheckbuttonZGROOVEÚ_TextViewer__toggletrackZ_TextViewer__tÚXZYESZFrameZ_TextViewer__frameÚ_TextViewer__labelsZLabelZgridÚEÚappendÚ_TextViewer__radiosZ RadiobuttonÚ_TextViewer__set_color)ÚselfZ switchboardZmasterr#ÚrootZsfgZsbgZibgr+ÚstartÚendÚframerrÚlÚcolÚr©rAúrArArBZ __toggletrack‚s   zTextViewer.__toggletrackcCs¾|j ¡}|j}|dkr"|d}nF|dkr4|d}n4|dkrF|d}n"|dkrX|d}n|d krh|d }yt |¡\}}}Wn,tjk r¨|j ¡ |¡\}}}YnX|j  |||¡dS) Nrr rr rr rrér) r1r(r)ÚColorDBZrrggbb_to_tripletZBadColorr"ZcolordbZ find_bynameZ update_views)r9rEÚwhichrZcolorÚredÚgreenÚbluerArArBZ __set_colorŽs"     zTextViewer.__set_colorcCsš|j ¡r–t |||f¡}|j ¡}|j}|dkr@|j|dnV|dkrV|j|dn@|dkrl|j|dn*|dkr‚|j|dn|d kr–|j|d dS) Nr)r r)r r)r r)rrH)r)r/r(rIZtriplet_to_rrggbbr1r)r*)r9rKrLrMZ colornamerJrrArArBÚupdate_yourself¢s  zTextViewer.update_yourselfcCs |j ¡|d<|j ¡|d<|j dd¡|d<|j t¡dd…|d<|j t¡|d <|jd |d <|jd |d <|jd|d<|jd|d<|jd|d<dS)Nrrgzend - 1crrrrrr rr rr r rrrr)r/r(r1r)Z tag_rangesr-Úindexr,)r9r#rArArBÚ save_options²szTextViewer.save_options)N)N)N)N)N)N)N) Ú__name__Ú __module__Ú __qualname__rCr'r%rFZ_TextViewer__forceupdater2r8rNrPrArArArBrs \     r)Ú__doc__ZtkinterrIZ ADDTOVIEWrrArArArBÚs