uQc@sMdZdZdZddddddd d d d d dddddddddddddgZddlZddlmZmZmZejdkre ne Z dZ e d Z e ed!Zd"Ze d#Ze d$Zd%d&d'Zd(Ze d)Zd*Zd+Zd,Zd-Zd.Zed/Zdefd0YZd1ejfd2YZdefd3YZdefd4YZ deej!fd5YZ!de!fd6YZ"defd7YZ#defd8YZ$d efd9YZ%e%Z&d efd:YZ'd efd;YZ(d eej)fd<YZ*e*Z)defd=YZ+defd>YZ,deej-fd?YZ-deej.fd@YZ.defdAYZ/defdBYZ0deej1ej2fdCYZ3de#efdDYZ4de'fdEYZ5dS(FsTtk wrapper. This module provides classes to allow using Tk themed widget set. Ttk is based on a revised and enhanced version of TIP #48 (http://tip.tcl.tk/48) specified style engine. Its basic idea is to separate, to the extent possible, the code implementing a widget's behavior from the code implementing its appearance. Widget class bindings are primarily responsible for maintaining the widget state and invoking callbacks, all aspects of the widgets appearance lies at Themes. s0.3.1s!Guilherme Polo tButtont CheckbuttontComboboxtEntrytFrametLabelt Labelframet LabelFramet MenubuttontNotebookt Panedwindowt PanedWindowt Progressbart RadiobuttontScalet Scrollbart SeparatortSizegriptStyletTreeviewt LabeledScalet OptionMenut tclobjs_to_pyt setup_masteriN(t_flattent_joint _stringifyg!@cCsatr]ddl}|jjd}|rA|jjd|n|jjdt|_ndS(Nit TILE_LIBRARYs(global auto_path; lappend auto_path {%s}spackage require tile(t _REQUIRE_TILEtostenvirontgetttktevaltTruet _tile_loaded(tmasterRttilelib((s /sys/lib/python2.7/lib-tk/ttk.pyt _load_tile"s   cCs=|rt|}n$t|ttfr9t|}n|S(sInternal function.(Rt isinstancetlistttupleR(tvaluetscript((s /sys/lib/python2.7/lib-tk/ttk.pyt_format_optvalue1s cCsyg}xf|jD]X\}}| s2||kr|jd||dk rk|jt||qkqqWt|S(sFormats optdict to a tuple to pass it to tk.call. E.g. (script=False): {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: ('-foreground', 'blue', '-padding', '1 2 3 4')s-%sN(t iteritemstappendtNoneR,R(toptdictR+tignoretoptstoptR*((s /sys/lib/python2.7/lib-tk/ttk.pyt_format_optdict;s  cCsg}x|D]}|d }|d}|dt|dkrT|dpNd}ndj|}|j||dk r |j|q q W|S(Niiitt (tlentjoinR.R/(titemstopt_valtitemtstatetval((s /sys/lib/python2.7/lib-tk/ttk.pyt_mapdict_valuesKs     cCsSg}x@|jD]2\}}|jd|tt||fqWt|S(sFormats mapdict to pass it to tk.call. E.g. (script=False): {'expand': [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]} returns: ('-expand', '{active selected} grey focus {1, 2, 3, 4}')s-%s(R-textendR,R>R(tmapdictR+R2R3R*((s /sys/lib/python2.7/lib-tk/ttk.pyt_format_mapdictds  c Osd }d }|d kr|dkrW|d}tt|d}d||f}n9|d \}} tt|d} d|| | f}t||}nD|dkr|d}t|dkrt|d|f}qn|rd |}d j|}n||fS(sAFormats args and kw according to the given element factory etype.timagetvsapiiis%s %sis%s %s %stfroms{%s}R6N((RBRC(R/RR>R4R7R,R8( tetypeR+targstkwtspecR2tinamet imagespect class_nametpart_idtstatemap((s /sys/lib/python2.7/lib-tk/ttk.pyt_format_elemcreateus&      iic Csg}x|D]}|\}}|p(i}djt|td }dd|||rcd|ndf}d|kr|j|d||7}t|d||\} }|j| ||8}|jdd|q |j|q Wdj||fS( s#Formats a layout list so we can pass the result to ttk::style layout and ttk::style settings. Note that the layout doesn't has to be a list necessarily. E.g.: [("Menubutton.background", None), ("Menubutton.button", {"children": [("Menubutton.focus", {"children": [("Menubutton.padding", {"children": [("Menubutton.label", {"side": "left", "expand": 1})] })] })] }), ("Menubutton.indicator", {"side": "right"}) ] returns: Menubutton.background Menubutton.button -children { Menubutton.focus -children { Menubutton.padding -children { Menubutton.label -side left -expand 1 } } } Menubutton.indicator -side rightR6tchildrens%s%s%ss %sR5s -children {s%s}s (RO(R8R4R"R.t_format_layoutlist( tlayouttindentt indent_sizeR+t layout_elemtelemR2tfoptstheadt newscript((s /sys/lib/python2.7/lib-tk/ttk.pyRPs    '     c Csg}x|jD]\}}|jdrddjt|dt}|jd||fn|jdrdjt|dt}|jd||fnd|kr|dsd}nt|d\}}|jd||fn|jd r|d }|d }d }x4|t|krWt ||d  rW|d 7}q$W|d |!} |t|kr||r||ni} t |t| | \} }|jd ||| |fqqWdj|S(sReturns an appropriate script, based on settings, according to theme_settings definition to be used by theme_settings and theme_create.t configureR6sttk::style configure %s %s;tmapsttk::style map %s %s;RQtnullsttk::style layout %s { %s }selement createiiR-s%ttk::style element create %s %s %s %ss ( R-RR8R4R"R.RARPR7thasattrRN( tsettingsR+tnameR2tst_teoptsREtargctelemargstelemkwRH((s /sys/lib/python2.7/lib-tk/ttk.pyt_script_from_settingss2     ) , cCsb|r dnd}i}t|}x1t||D] \}}||t||> event.sreturn $ttk::currentThemes ttk::setThemeN(R/R R!R(RR((s /sys/lib/python2.7/lib-tk/ttk.pyt theme_uses N(t__name__t __module__t__doc__RR/RRYRZRRQRRRRRRR(((s /sys/lib/python2.7/lib-tk/ttk.pyRls  +    tWidgetcBs;eZdZddZdZddZddZRS(s!Base class for Tk themed widgets.cCsKt|}t|dts+t|ntjj|||d|dS(sConstructs a Ttk Widget with the parent master. STANDARD OPTIONS class, cursor, takefocus, style SCROLLABLE WIDGET OPTIONS xscrollcommand, yscrollcommand LABEL WIDGET OPTIONS text, textvariable, underline, image, compound, width WIDGET STATES active, disabled, focus, pressed, selected, background, readonly, alternate, invalid R#RGN(RRqRR&RRR(RR$t widgetnameRG((s /sys/lib/python2.7/lib-tk/ttk.pyRs  cCs|jj|jd||S(sReturns the name of the element at position x, y, or the empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget.tidentify(R Rt_w(Rtxty((s /sys/lib/python2.7/lib-tk/ttk.pyR.scOsG|jj|jddj|}|r=|r=|||St|S(s1Test the widget's state. If callback is not specified, returns True if the widget state matches statespec and False otherwise. If callback is specified, then it will be invoked with *args, **kw if the widget state matches statespec. statespec is expected to be a sequence.tinstateR6(R RRR8tbool(Rt statespectcallbackRFRGtret((s /sys/lib/python2.7/lib-tk/ttk.pyR6s$  cCsI|dk rdj|}n|jjt|jj|jd|S(sModify or inquire widget state. Widget state is returned if statespec is None, otherwise it is set according to the statespec flags and then a new state spec is returned indicating which flags were changed. statespec is expected to be a sequence.R6R<N(R/R8R t splitlistRhRR(RR((s /sys/lib/python2.7/lib-tk/ttk.pyR<Ds N(RRRR/RRRR<(((s /sys/lib/python2.7/lib-tk/ttk.pyRs    cBs#eZdZddZdZRS(scTtk Button widget, displays a textual label and/or image, and evaluates a command when pressed.cKstj||d|dS(sConstruct a Ttk Button widget with the parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, default, width s ttk::buttonN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRUs cCs|jj|jdS(s/Invokes the command associated with the button.tinvoke(R RR(R((s /sys/lib/python2.7/lib-tk/ttk.pyRdsN(RRRR/RR(((s /sys/lib/python2.7/lib-tk/ttk.pyRQs cBs#eZdZddZdZRS(s;Ttk Checkbutton widget which is either in on- or off-state.cKstj||d|dS(s'Construct a Ttk Checkbutton widget with the parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS command, offvalue, onvalue, variable sttk::checkbuttonN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRls cCs|jj|jdS(sWToggles between the selected and deselected states and invokes the associated command. If the widget is currently selected, sets the option variable to the offvalue option and deselects the widget; otherwise, sets the option variable to the option onvalue. Returns the result of the associated command.R(R RR(R((s /sys/lib/python2.7/lib-tk/ttk.pyR{sN(RRRR/RR(((s /sys/lib/python2.7/lib-tk/ttk.pyRis cBs8eZdZdddZdZdZdZRS(seTtk Entry widget displays a one-line text string and allows that string to be edited by the user.cKs tj|||pd|dS(sConstructs a Ttk Entry widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus, xscrollcommand WIDGET-SPECIFIC OPTIONS exportselection, invalidcommand, justify, show, state, textvariable, validate, validatecommand, width VALIDATION MODES none, key, focus, focusin, focusout, all s ttk::entryN(RR(RR$twidgetRG((s /sys/lib/python2.7/lib-tk/ttk.pyRscCs|jj|jd|S(sqReturn a tuple of (x, y, width, height) which describes the bounding box of the character given by index.tbbox(R RR(Rtindex((s /sys/lib/python2.7/lib-tk/ttk.pyRscCs|jj|jd||S(sxReturns the name of the element at position x, y, or the empty string if the coordinates are outside the window.R(R RR(RRR((s /sys/lib/python2.7/lib-tk/ttk.pyRscCst|jj|jdS(sForce revalidation, independent of the conditions specified by the validate option. Returns False if validation fails, True if it succeeds. Sets or clears the invalid state accordingly.tvalidate(RR RR(R((s /sys/lib/python2.7/lib-tk/ttk.pyRsN(RRRR/RRRR(((s /sys/lib/python2.7/lib-tk/ttk.pyRs   cBs/eZdZddZddZdZRS(sMTtk Combobox widget combines a text field with a pop-down list of values.cKstj||d|dS(sConstruct a Ttk Combobox widget with the parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS exportselection, justify, height, postcommand, state, textvariable, values, width s ttk::comboboxN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRs cCs|jj|jd|S(sIf newindex is supplied, sets the combobox value to the element at position newindex in the list of values. Otherwise, returns the index of the current value in the list of values or -1 if the current value does not appear in the list.tcurrent(R RR(Rtnewindex((s /sys/lib/python2.7/lib-tk/ttk.pyRscCs|jj|jd|dS(s(Sets the value of the combobox to value.tsetN(R RR(RR*((s /sys/lib/python2.7/lib-tk/ttk.pyRsN(RRRR/RRR(((s /sys/lib/python2.7/lib-tk/ttk.pyRs  cBseZdZddZRS(sJTtk Frame widget is a container, used to group other widgets together.cKstj||d|dS(sConstruct a Ttk Frame with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS borderwidth, relief, padding, width, height s ttk::frameN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRs N(RRRR/R(((s /sys/lib/python2.7/lib-tk/ttk.pyRscBseZdZddZRS(s7Ttk Label widget displays a textual label and/or image.cKstj||d|dS(sGConstruct a Ttk Label with parent master. STANDARD OPTIONS class, compound, cursor, image, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS anchor, background, font, foreground, justify, padding, relief, text, wraplength s ttk::labelN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRs N(RRRR/R(((s /sys/lib/python2.7/lib-tk/ttk.pyRscBseZdZddZRS(sTtk Labelframe widget is a container used to group other widgets together. It has an optional label, which may be a plain text string or another widget.cKstj||d|dS(sConstruct a Ttk Labelframe with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS labelanchor, text, underline, padding, labelwidget, width, height sttk::labelframeN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRs N(RRRR/R(((s /sys/lib/python2.7/lib-tk/ttk.pyRscBseZdZddZRS(sbTtk Menubutton widget displays a textual label and/or image, and displays a menu when pressed.cKstj||d|dS(sConstruct a Ttk Menubutton with parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS direction, menu sttk::menubuttonN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRs N(RRRR/R(((s /sys/lib/python2.7/lib-tk/ttk.pyR scBszeZdZd dZdZdZdZdZdZ dZ d dZ d d Z d Z d ZRS( sTtk Notebook widget manages a collection of windows and displays a single one at a time. Each child window is associated with a tab, which the user may select to change the currently-displayed window.cKstj||d|dS(s\Construct a Ttk Notebook with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS height, padding, width TAB OPTIONS state, sticky, padding, text, image, compound, underline TAB IDENTIFIERS (tab_id) The tab_id argument found in several methods may take any of the following forms: * An integer between zero and the number of tabs * The name of a child window * A positional specification of the form "@x,y", which defines the tab * The string "current", which identifies the currently-selected tab * The string "end", which returns the number of tabs (only valid for method index) s ttk::notebookN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyR"scKs&|jj|jd|t|dS(sAdds a new tab to the notebook. If window is currently managed by the notebook but hidden, it is restored to its previous position.taddN(R RRR4(RtchildRG((s /sys/lib/python2.7/lib-tk/ttk.pyRBscCs|jj|jd|dS(sXRemoves the tab specified by tab_id, unmaps and unmanages the associated window.tforgetN(R RR(Rttab_id((s /sys/lib/python2.7/lib-tk/ttk.pyRJscCs|jj|jd|dS(sHides the tab specified by tab_id. The tab will not be displayed, but the associated window remains managed by the notebook and its configuration remembered. Hidden tabs may be restored with the add command.thideN(R RR(RR((s /sys/lib/python2.7/lib-tk/ttk.pyRPscCs|jj|jd||S(sZReturns the name of the tab element at position x, y, or the empty string if none.R(R RR(RRR((s /sys/lib/python2.7/lib-tk/ttk.pyRYscCs|jj|jd|S(s|Returns the numeric index of the tab specified by tab_id, or the total number of tabs if tab_id is the string "end".R(R RR(RR((s /sys/lib/python2.7/lib-tk/ttk.pyR_scKs)|jj|jd||t|dS(sInserts a pane at the specified position. pos is either the string end, an integer index, or the name of a managed child. If child is already managed by the notebook, moves it to the specified position.tinsertN(R RRR4(RtposRRG((s /sys/lib/python2.7/lib-tk/ttk.pyRescCs|jj|jd|S(sSelects the specified tab. The associated child window will be displayed, and the previously-selected window (if different) is unmapped. If tab_id is omitted, returns the widget name of the currently selected pane.tselect(R RR(RR((s /sys/lib/python2.7/lib-tk/ttk.pyRnscKs8|dk rd||> event.RDtfrom_ttos<>N(tupdateRRYtanytevent_generate(RtcnfRG((s /sys/lib/python2.7/lib-tk/ttk.pyRY5s 'cCs|jj|jd||S(sGet the current value of the value option, or the value corresponding to the coordinates x, y if they are specified. x and y are pixel coordinates relative to the scale widget origin.R(R RR(RRR((s /sys/lib/python2.7/lib-tk/ttk.pyRAsN(RRRR/RRYR(((s /sys/lib/python2.7/lib-tk/ttk.pyR#s  cBseZdZddZRS(s;Ttk Scrollbar controls the viewport of a scrollable widget.cKstj||d|dS(sConstruct a Ttk Scrollbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, orient sttk::scrollbarN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRMs N(RRRR/R(((s /sys/lib/python2.7/lib-tk/ttk.pyRJscBseZdZddZRS(sITtk Separator widget displays a horizontal or vertical separator bar.cKstj||d|dS(sConstruct a Ttk Separator with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient sttk::separatorN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyR_s N(RRRR/R(((s /sys/lib/python2.7/lib-tk/ttk.pyR[scBseZdZddZRS(slTtk Sizegrip allows the user to resize the containing toplevel window by pressing and dragging the grip.cKstj||d|dS(sConstruct a Ttk Sizegrip with parent master. STANDARD OPTIONS class, cursor, state, style, takefocus s ttk::sizegripN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRqsN(RRRR/R(((s /sys/lib/python2.7/lib-tk/ttk.pyRmscBsdeZdZd!dZd!dZd!dZdZd!dZdZ dZ dZ d!d Z d!d Z d Zd Zd ZdZdZdZd!dZd!dZdZeZdZdZdZdZd!d!dZdZdZdZdZ d!d!dZ!d!d!dZ"d!dZ#d!d Z$RS("sTtk Treeview widget displays a hierarchical collection of items. Each item has a textual label, an optional image, and an optional list of data values. The data values are displayed in successive columns after the tree label.cKstj||d|dS(sConstruct a Ttk Treeview with parent master. STANDARD OPTIONS class, cursor, style, takefocus, xscrollcommand, yscrollcommand WIDGET-SPECIFIC OPTIONS columns, displaycolumns, height, padding, selectmode, show ITEM OPTIONS text, image, values, open, tags TAG OPTIONS foreground, background, font, image s ttk::treeviewN(RR(RR$RG((s /sys/lib/python2.7/lib-tk/ttk.pyRscCs|jj|jd||S(sTReturns the bounding box (relative to the treeview widget's window) of the specified item in the form x y width height. If column is specified, returns the bounding box of that cell. If the item is not visible (i.e., if it is a descendant of a closed item or is scrolled offscreen), returns an empty string.R(R RR(RR;tcolumn((s /sys/lib/python2.7/lib-tk/ttk.pyRscCs%|jj|jd|pdp$dS(shReturns a tuple of children belonging to item. If item is not specified, returns root children.ROR5((R RR(RR;((s /sys/lib/python2.7/lib-tk/ttk.pyt get_childrenscGs |jj|jd||dS(sReplaces item's child with newchildren. Children present in item that are not present in newchildren are detached from tree. No items in newchildren may be an ancestor of item.RON(R RR(RR;t newchildren((s /sys/lib/python2.7/lib-tk/ttk.pyt set_childrenscKs8|dk rd||>tbottomtsidetfillRtanchortnR_tws sN(tpopt _label_topRRRtIntVart _variableRt _last_validRtlabelRtscaleRt_adjusttpacktplacettrace_variablet_LabeledScale__tracecb( RR$RRRRGt scale_sidet label_sidettmp((s /sys/lib/python2.7/lib-tk/ttk.pyRs  $%cCsEy|jjd|jWntk r-nX|`tj|dS(s9Destroy this widget and possibly its associated variable.R N(R t trace_vdeleteRtAttributeErrorRtdestroy(R((s /sys/lib/python2.7/lib-tk/ttk.pyRs  csfd}jdjd}}||krF||}}njj}||kol|knsj_dS|_|jd<j|dS(s1Adjust the label position according to the scale.csjjj\}}jrGjjjj}njjjj}jjd|d|dS(NRR(tupdate_idletasksRtcoordsR twinfo_yRtwinfo_reqheighttplace_configure(RR(R(s /sys/lib/python2.7/lib-tk/ttk.pyt adjust_labels   RDRNttext(RR RRR*Rt after_idle(RRFR!RRtnewval((Rs /sys/lib/python2.7/lib-tk/ttk.pyRs     cCs |jjS(sReturn current scale value.(R R(R((s /sys/lib/python2.7/lib-tk/ttk.pyt _get_valuescCs|jj|dS(sSet new scale value.N(R R(RR=((s /sys/lib/python2.7/lib-tk/ttk.pyt _set_value sN( RRRR/RRRR%R&tpropertyR*(((s /sys/lib/python2.7/lib-tk/ttk.pyRs#   cBs8eZdZddZdZddZdZRS(smThemed OptionMenu, based after Tkinter's OptionMenu, which allows the user to select a value from a menu.cOsi|d6|jddd6|jddd6}tj|||tj|dt|d<||_|jdd|_|rtj d|j j n|j ||dS( s9Construct a themed OptionMenu widget with master as the parent, the resource textvariable set to variable, the initially selected value specified by the default parameter, the menu values given by *values and additional keywords. WIDGET-SPECIFIC OPTIONS style: stylename Menubutton style. direction: 'above', 'below', 'left', 'right', or 'flush' Menubutton direction. command: callback A callback that will be invoked after selecting an item. t textvariableRt directionttearofftmenuRsunknown option -%sN( R R/RRRtMenuRR t _callbacktTclErrortiterkeysRtset_menu(RR$RRtvaluestkwargsRG((s /sys/lib/python2.7/lib-tk/ttk.pyRs  cCs5|dkr%|jtj||Stj||S(NR+(t nametowidgetRt __getitem__(RR;((s /sys/lib/python2.7/lib-tk/ttk.pyR42s c Gss|d}|jddx9|D]1}|jd|dtj|j||jq!W|ro|jj|ndS(sUBuild a new menu of radiobuttons with *values and optionally a default value.R+itendRRN(Rtadd_radiobuttonRt_setitR R-R(RRR1R+R=((s /sys/lib/python2.7/lib-tk/ttk.pyR09s   cCs|`tj|dS(s0Destroy this widget and its associated variable.N(R RR(R((s /sys/lib/python2.7/lib-tk/ttk.pyRFsN(RRRR/RR4R0R(((s /sys/lib/python2.7/lib-tk/ttk.pyRs    (6Rt __version__t __author__t__all__RRRRt TkVersionR"RRR&R,R/R4R>RARNRPReRnRuRxR~RRRtobjectRRRRRRRRRRRR R R R R RRRRtXViewtYViewRRR(((s /sys/lib/python2.7/lib-tk/ttk.pyt sd        %1 *      A* 8*'"9^