[1@sdZdZdZddddddd d d d d dddddddddddddgZddlZddlmZmZmZmZej dkrdnd Z d!d"Z d d#d$Z d dd%d&Z d'd(Zd d)d*Zd d+d,Zdd-d.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zd<d=Zd>dZdd?dZGd@ddeZGdAdBdBejZGdCddeZGdDddeZGdEddeej Z GdFdde Z!GdGddeZ"GdHddeZ#GdId d eZ$e$Z%GdJd d eZ&GdKd d eZ'GdLd d eej(Z)e)Z(GdMddeZ*GdNddeZ+GdOddeej,Z,GdPddeej-Z-GdQddeZ.GdRddeZ/GdSddeej0ej1Z2GdTdde"Z3GdUdde&Z4dS)VaTtk 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. z0.3.1z!Guilherme Polo Button CheckbuttonComboboxEntryFrameLabel Labelframe LabelFrame MenubuttonNotebook Panedwindow PanedWindow Progressbar RadiobuttonScale Scrollbar SeparatorSizegripStyleTreeview LabeledScale OptionMenu tclobjs_to_py setup_masterN)_flatten_join _stringify _splitdictg!@TFcCsatr]ddl}|jjd}|rA|jjd|n|jjdd|_ndS)NrZ TILE_LIBRARYz(global auto_path; lappend auto_path {%s}zpackage require tileT) _REQUIRE_TILEosenvirongettkeval _tile_loaded)masterrZtilelibr&!/usr/lib/python3.4/tkinter/ttk.py _load_tile"s   r(cCs=|rt|}n$t|ttfr9t|}n|S)zInternal function.)r isinstancelisttupler)valuescriptr&r&r'_format_optvalue1s r.cCsyg}xf|jD]X\}}| s2||kr|jd||dk rk|jt||qkqqWt|S)zFormats 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')z-%sN)itemsappendr.r)Zoptdictr-ignoreoptsoptr,r&r&r'_format_optdict;s  r4cCsg}xy|D]q^}}|dt|dkrF|dp@d}ndj|}|j||dk r |j|q q W|S)Nr )lenjoinr0)r/Zopt_valstatevalr&r&r'_mapdict_valuesKs  r<cCsSg}x@|jD]2\}}|jd|tt||fqWt|S)zFormats 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}')z-%s)r/extendr.r<r)Zmapdictr-r2r3r,r&r&r'_format_mapdictbs  r>c Os$d}f}|d kr|dkr]|d}tt|dd}d||f}nE|dd\}} tt|dd} d|| | f}t||}nD|d kr|d}t|dkrt|d|f}qn|rd |}d j|}n||fS) zAFormats args and kw according to the given element factory etype.Nimagevsapirr5z%s %sz%s %s %sfromz{%s}r7)r?r@)rr<r4r8r.r9) etyper-argskwspecr2ZinameZ imagespecZ class_nameZpart_idZstatemapr&r&r'_format_elemcreatess&      rGrAc Csg}x|D]}|\}}|p(i}djt|dd }dd|||rcd|ndf}d|kr|j|d||7}t|d||\} }|j| ||8}|jdd|q |j|q Wd j||fS) a#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 rightr7Tchildrenz%s%s%sz %sr6z -children {z%s} )rH)r9r4r0_format_layoutlist) layoutindentZ indent_sizer-Z layout_elemelemr2ZfoptsheadZ newscriptr&r&r'rJs    '     rJc Csg}x|jD]\}}|jdrddjt|dd}|jd||fn|jdrdjt|dd}|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 |d| | \} }|jd||| |fqqWdj|S)zReturns an appropriate script, based on settings, according to theme_settings definition to be used by theme_settings and theme_create. configurer7Tzttk::style configure %s %s;mapzttk::style map %s %s;rKnullzttk::style layout %s { %s }zelement createrr5r/z%ttk::style element create %s %s %s %srI) r/r!r9r4r0r>rJr8hasattrrG) settingsr-namer2s_ZeoptsrCZargcZelemargsZelemkwrFr&r&r'_script_from_settingss2     ), rWcCsg}xp|D]h}t|dd}|dkrA|j|q t|}|dkrh|j}n|j|q Wt|}ddt||DS)ztConstruct a list from the given statespec tuple according to the accepted statespec accepted by _format_mapdict.typenameN StateSpeccSsg|]}t|qSr&)r).0rFr&r&r' s z(_list_from_statespec..)getattrr0strsplititerzip)ZstupleZnvalr;rXitr&r&r'_list_from_statespecs     rbcCs|j|}g}d}x|t|kr||}i}|j||f|d7}x|t|kr|||d\}}|jdsPn|dd}|d7}|dkrt||}n|||t|jj|jj|jd|d|St|j|jj|jd|t|dtS)aSQuery or sets dynamic values of the specified option(s) in style. Each key in kw is an option and each value should be a list or a tuple (usually) containing statespecs grouped in tuples, or list, or something else of your preference. A statespec is compound of one or more states and then a value.NrPz-%srh)rbr"rdrirzrr>rj)rxr{r|rEr&r&r'rPs  &$z Style.mapcCsA|rdj|nd}|jj|jd|d|||S)aReturns the value specified for option in style. If state is specified it is expected to be a sequence of one or more states. If the default argument is set, it is used as a fallback value in case no specification for option is found.r7r6lookupz-%s)r9r"rirz)rxr{optionr:defaultr&r&r'r}sz Style.lookupcCs\d}|rt|d}n|dk r4d}nt|j|jj|jd||S)aDefine the widget layout for given style. If layoutspec is omitted, return the layout specification for given style. layoutspec is expected to be a list or an object different than None that evaluates to False if you want to "turn off" that style. If it is a list (or tuple, or something else), each item should be a tuple where the first item is the layout name and the second item should have the format described below: LAYOUTS A layout can contain the value None, if takes no options, or a dict of options specifying how to arrange the element. The layout mechanism uses a simplified version of the pack geometry manager: given an initial cavity, each element is allocated a parcel. Valid options/values are: side: whichside Specifies which side of the cavity to place the element; one of top, right, bottom or left. If omitted, the element occupies the entire cavity. sticky: nswe Specifies where the element is placed inside its allocated parcel. children: [sublayout... ] Specifies a list of elements to place inside the element. Each element is a tuple (or other sequence) where the first item is the layout name, and the other is a LAYOUT.NrrQrK)rJrfr"rirz)rxr{Z layoutspecZlspecr&r&r'rKs    z Style.layoutcOsDt|d||\}}|jj|jdd||||dS)z9Create a new element in the current theme of given etype.FelementcreateN)rGr"rirz)rx elementnamerCrDrErFr2r&r&r'element_createszStyle.element_createcCs%|jj|jj|jddS)z:Returns the list of elements defined in the current theme.rnames)r"rdrirz)rxr&r&r' element_namesszStyle.element_namescCs(|jj|jj|jdd|S)z)Return the list of elementname's options.rrk)r"rdrirz)rxrr&r&r'element_optionsszStyle.element_optionsc Cso|rt|nd}|rI|jj|jdd|d|d|n"|jj|jdd|d|dS)a.Creates a new theme. It is an error if themename already exists. If parent is specified, the new theme will inherit styles, elements and layouts from the specified parent theme. If settings are present, they are expected to have the same syntax used for theme_settings.r6themerz-parentz -settingsN)rWr"rirz)rx themenameparentrSr-r&r&r' theme_creates zStyle.theme_createcCs/t|}|jj|jdd||dS)aTemporarily sets the current theme to themename, apply specified settings and then restore the previous theme. Each key in settings is a style and each value may contain the keys 'configure', 'map', 'layout' and 'element create' and they are expected to have the same format as specified by the methods configure, map, layout and element_create respectively.rrSN)rWr"rirz)rxrrSr-r&r&r'theme_settingss zStyle.theme_settingscCs%|jj|jj|jddS)z#Returns a list of all known themes.rr)r"rdrirz)rxr&r&r' theme_namesszStyle.theme_namescCs3|dkr|jjdS|jjd|dS)zIf themename is None, returns the theme in use, otherwise, set the current theme to themename, refreshes all widgets and emits a <> event.Nzreturn $ttk::currentThemez ttk::setTheme)r"r#ri)rxrr&r&r' theme_uses zStyle.theme_use)__name__ __module__ __qualname____doc__rzryrOrPr}rKrrrrrrrr&r&r&r'rhs    +    c@sOeZdZdZdddZddZdddZdd d ZdS) Widgetz!Base class for Tk themed widgets.NcCsKt|}t|dds+t|ntjj|||d|dS)aConstructs 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$FrEN)rr\r(rvrry)rxr%Z widgetnamerEr&r&r'rys  zWidget.__init__cCs|jj|jd||S)zReturns 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.identify)r"ri_w)rxrsyr&r&r'r,szWidget.identifycOsS|jj|jj|jddj|}|rI|rI|||St|S)a1Test 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.instater7)r" getbooleanrirr9bool)rx statespeccallbackrDrEZretr&r&r'r4s  '  zWidget.instatecCsI|dk rdj|}n|jjt|jj|jd|S)aModify 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.Nr7r:)r9r"rdr]rir)rxrr&r&r'r:Cs z Widget.state)rrrrryrrr:r&r&r&r'rs  rc@s1eZdZdZdddZddZdS)rzcTtk Button widget, displays a textual label and/or image, and evaluates a command when pressed.NcKstj||d|dS)aConstruct 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 z ttk::buttonN)rry)rxr%rEr&r&r'ryTs zButton.__init__cCs|jj|jdS)z/Invokes the command associated with the button.invoke)r"rir)rxr&r&r'rcsz Button.invoke)rrrrryrr&r&r&r'rPs c@s1eZdZdZdddZddZdS)rz;Ttk Checkbutton widget which is either in on- or off-state.NcKstj||d|dS)a'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 zttk::checkbuttonN)rry)rxr%rEr&r&r'ryks zCheckbutton.__init__cCs|jj|jdS)aWToggles 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"rir)rxr&r&r'rzszCheckbutton.invoke)rrrrryrr&r&r&r'rhs c@sLeZdZdZddddZddZddZd d ZdS) rzeTtk Entry widget displays a one-line text string and allows that string to be edited by the user.NcKs tj|||pd|dS)aConstructs 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 z ttk::entryN)rry)rxr%ZwidgetrEr&r&r'ryszEntry.__init__cCs"|j|jj|jd|S)zqReturn a tuple of (x, y, width, height) which describes the bounding box of the character given by index.bbox)_getintsr"rir)rxindexr&r&r'rsz Entry.bboxcCs|jj|jd||S)zxReturns the name of the element at position x, y, or the empty string if the coordinates are outside the window.r)r"rir)rxrsrr&r&r'rszEntry.identifycCs(t|jj|jj|jdS)zForce 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.validate)rr"rrir)rxr&r&r'rszEntry.validate)rrrrryrrrr&r&r&r'rs   c@s@eZdZdZdddZdddZddZdS) rzMTtk Combobox widget combines a text field with a pop-down list of values.NcKstj||d|dS)aConstruct 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 z ttk::comboboxN)rry)rxr%rEr&r&r'rys zCombobox.__init__cCsG|dkr.|jj|jj|jdS|jj|jd|S)aIf 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.Ncurrent)r"getintrir)rxZnewindexr&r&r'rs "zCombobox.currentcCs|jj|jd|dS)z(Sets the value of the combobox to value.setN)r"rir)rxr,r&r&r'rsz Combobox.set)rrrrryrrr&r&r&r'rs  c@s%eZdZdZdddZdS)rzJTtk Frame widget is a container, used to group other widgets together.NcKstj||d|dS)zConstruct a Ttk Frame with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS borderwidth, relief, padding, width, height z ttk::frameN)rry)rxr%rEr&r&r'rys zFrame.__init__)rrrrryr&r&r&r'rs c@s%eZdZdZdddZdS)rz7Ttk Label widget displays a textual label and/or image.NcKstj||d|dS)aGConstruct 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 z ttk::labelN)rry)rxr%rEr&r&r'rys zLabel.__init__)rrrrryr&r&r&r'rs c@s%eZdZdZdddZdS)rzTtk 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.NcKstj||d|dS)zConstruct a Ttk Labelframe with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS labelanchor, text, underline, padding, labelwidget, width, height zttk::labelframeN)rry)rxr%rEr&r&r'rys zLabelframe.__init__)rrrrryr&r&r&r'rs c@s%eZdZdZdddZdS)r zbTtk Menubutton widget displays a textual label and/or image, and displays a menu when pressed.NcKstj||d|dS)aConstruct a Ttk Menubutton with parent master. STANDARD OPTIONS class, compound, cursor, image, state, style, takefocus, text, textvariable, underline, width WIDGET-SPECIFIC OPTIONS direction, menu zttk::menubuttonN)rry)rxr%rEr&r&r'rys zMenubutton.__init__)rrrrryr&r&r&r'r s c@seZdZdZdddZddZddZd d Zd d Zd dZ ddZ dddZ dddZ ddZ ddZdS)r zTtk 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.NcKstj||d|dS)a\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) z ttk::notebookN)rry)rxr%rEr&r&r'ry#szNotebook.__init__cKs&|jj|jd|t|dS)zAdds a new tab to the notebook. If window is currently managed by the notebook but hidden, it is restored to its previous position.addN)r"rirr4)rxchildrEr&r&r'rCsz Notebook.addcCs|jj|jd|dS)zXRemoves the tab specified by tab_id, unmaps and unmanages the associated window.forgetN)r"rir)rxtab_idr&r&r'rKszNotebook.forgetcCs|jj|jd|dS)zHides 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.hideN)r"rir)rxrr&r&r'rQsz Notebook.hidecCs|jj|jd||S)zZReturns the name of the tab element at position x, y, or the empty string if none.r)r"rir)rxrsrr&r&r'rZszNotebook.identifycCs%|jj|jj|jd|S)z|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"rrir)rxrr&r&r'r`szNotebook.indexcKs)|jj|jd||t|dS)zInserts 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.insertN)r"rirr4)rxposrrEr&r&r'rfszNotebook.insertcCs|jj|jd|S)zSelects 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.select)r"rir)rxrr&r&r'roszNotebook.selectcKs5|dk rd||> event.rBfrom_toz<>N)updaterrOanyZevent_generate)rxZcnfrEr&r&r'rO6s 'zScale.configurecCs|jj|jd||S)zGet 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"rir)rxrsrr&r&r'r!Bsz Scale.get)rrrrryrOr!r&r&r&r'r$s  c@s%eZdZdZdddZdS)rz;Ttk Scrollbar controls the viewport of a scrollable widget.NcKstj||d|dS)zConstruct a Ttk Scrollbar with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS command, orient zttk::scrollbarN)rry)rxr%rEr&r&r'ryNs zScrollbar.__init__)rrrrryr&r&r&r'rKs c@s%eZdZdZdddZdS)rzITtk Separator widget displays a horizontal or vertical separator bar.NcKstj||d|dS)zConstruct a Ttk Separator with parent master. STANDARD OPTIONS class, cursor, style, takefocus WIDGET-SPECIFIC OPTIONS orient zttk::separatorN)rry)rxr%rEr&r&r'ry`s zSeparator.__init__)rrrrryr&r&r&r'r\s c@s%eZdZdZdddZdS)rzlTtk Sizegrip allows the user to resize the containing toplevel window by pressing and dragging the grip.NcKstj||d|dS)zConstruct a Ttk Sizegrip with parent master. STANDARD OPTIONS class, cursor, state, style, takefocus z ttk::sizegripN)rry)rxr%rEr&r&r'ryrszSizegrip.__init__)rrrrryr&r&r&r'rns c@seZdZdZdddZdddZdddZd d Zdd d Zd dZ ddZ ddZ dddZ dddZ ddZddZddZddZdd Zd!d"Zdd#d$Zdd%d&Zd'd(ZeZd)d*Zd+d,Zd-d.Zd/d0Zddd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z ddd;d<Z!ddd=d>Z"dd?d@Z#ddAdBZ$dS)CrzTtk 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.NcKstj||d|dS)aConstruct 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 z ttk::treeviewN)rry)rxr%rEr&r&r'ryszTreeview.__init__cCs+|j|jj|jd||p*dS)aTReturns 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.rr6)rr"rir)rxitemcolumnr&r&r'rsz Treeview.bboxcCs1|jj|jj|jd|p$dp-fS)zhReturns a tuple of children belonging to item. If item is not specified, returns root children.rHr6)r"rdrir)rxrr&r&r' get_childrens zTreeview.get_childrencGs |jj|jd||dS)zReplaces 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.rHN)r"rir)rxrZ newchildrenr&r&r' set_childrenszTreeview.set_childrencKs5|dk rd||s  z Treeview.itemcCs#|jj|jd|||dS)aRMoves item to position index in parent's list of children. It is illegal to move an item under one of its descendants. If index is less than or equal to zero, item is moved to the beginning, if greater than or equal to the number of children, it is moved to the end. If item was detached it is reattached.moveN)r"rir)rxrrrr&r&r'rJsz Treeview.movecCs|jj|jd|S)zeReturns the identifier of item's next sibling, or '' if item is the last child of its parent.next)r"rir)rxrr&r&r'rVsz Treeview.nextcCs|jj|jd|S)zaReturns the ID of the parent of item, or '' if item is at the top level of the hierarchy.r)r"rir)rxrr&r&r'r\szTreeview.parentcCs|jj|jd|S)zjReturns the identifier of item's previous sibling, or '' if item is the first child of its parent.prev)r"rir)rxrr&r&r'rbsz Treeview.prevcCs|jj|jd|dS)zEnsure that item is visible. Sets all of item's ancestors open option to True, and scrolls the widget if necessary so that item is within the visible portion of the tree.seeN)r"rir)rxrr&r&r'rhsz Treeview.seecCs|jj|jd||S)z2If selop is not specified, returns selected items. selection)r"rir)rxZselopr/r&r&r'rqszTreeview.selectioncCs|jd|dS)z items becomes the new selection.rN)r)rxr/r&r&r' selection_setvszTreeview.selection_setcCs|jd|dS)zAdd items to the selection.rN)r)rxr/r&r&r' selection_add{szTreeview.selection_addcCs|jd|dS)z Remove items from the selection.removeN)r)rxr/r&r&r'selection_removeszTreeview.selection_removecCs|jd|dS)z1Toggle the selection state of each item in items.ZtoggleN)r)rxr/r&r&r'selection_toggleszTreeview.selection_togglecCs]|jj|jd|||}|dkrU|dkrUt|j|dddtS|SdS)a;Query or set the value of given item. With one argument, return a dictionary of column/value pairs for the specified item. With two arguments, return the current value of the specified column. With three arguments, set the value of given column in given item to the specified value.rNZ cut_minusFrh)r"rirrrj)rxrrr,rgr&r&r'rs ! z Treeview.setcCs,|j|jdd|f||dddS)zBind a callback for the given event sequence to the tag tagname. When an event is delivered to an item, the callbacks for each of the item's tags option are called.tagbindrrN)Z_bindr)rxtagnameZsequencerr&r&r'tag_bindszTreeview.tag_bindcKs8|dk rd||>ZbottomZsideZfillrsZanchornrUwz zN)pop _label_toprryrvZIntVar _variabler _last_validrlabelrscaler_adjustZpackZplaceZtrace_variable_LabeledScale__tracecb) rxr%rrrrEZ scale_sideZ label_sideZtmpr&r&r'rys  $%zLabeledScale.__init__c CsFy|jjd|jWntk r.YnX|`tj|dS)z9Destroy this widget and possibly its associated variable.rN)rZ trace_vdeleterAttributeErrorrdestroy)rxr&r&r'rs  zLabeledScale.destroycsfdd}tjd}tjd}||krT||}}njj}||koz|knsj_dS|_|jd<j|dS)z1Adjust the label position according to the scale.csjjj\}}jrGjjjj}njjjj}jjd|d|dS)Nrsr)Zupdate_idletasksrZcoordsrZwinfo_yrZwinfo_reqheightZplace_configure)rsr)rxr&r' adjust_labels   z*LabeledScale._adjust..adjust_labelrBrNtext)rtrrr!rr,rZ after_idle)rxrDrrrZnewvalr&)rxr'rs     zLabeledScale._adjustcCs |jjS)zReturn current scale value.)rr!)rxr&r&r' _get_valueszLabeledScale._get_valuecCs|jj|dS)zSet new scale value.N)rr)rxr;r&r&r' _set_valueszLabeledScale._set_value) rrrrryrrrrpropertyr,r&r&r&r'rs #   c@sLeZdZdZdddZddZdddZd d ZdS) rzmThemed OptionMenu, based after tkinter's OptionMenu, which allows the user to select a value from a menu.NcOsi|d6|jddd6|jddd6}tj|||tj|dd|d<||_|jdd|_|rtjd tt |j n|j ||dS) a9Construct 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. Z textvariabler{NZ directionZtearoffFmenurzunknown option -%s) rr ryrvZMenur _callbackZTclErrorrr_keysset_menu)rxr%rrvalueskwargsrEr&r&r'ry s  zOptionMenu.__init__cCs5|dkr%|jtj||Stj||S)Nr)Z nametowidgetr __getitem__)rxrr&r&r'r=s zOptionMenu.__getitem__c Gss|d}|jddx9|D]1}|jd|dtj|j||jq!W|ro|jj|ndS)zUBuild a new menu of radiobuttons with *values and optionally a default value.rrendrrN)rZadd_radiobuttonrvZ_setitrrr)rxrrrr;r&r&r'rDs   zOptionMenu.set_menucCs|`tj|dS)z0Destroy this widget and its associated variable.N)rr r)rxr&r&r'rQszOptionMenu.destroy)rrrrryrrrr&r&r&r'rs   )5r __version__ __author____all__rvrrrrZ TkVersionrr(r.r4r<r>rGrJrWrbrfrlrprtrjrrobjectrrrrrrrrrrr r r r r rrrrrZXViewZYViewrrrr&r&r&r' sf   "   %1 *     B*"8*'"B_