ó <¿CVc@s•dZddlZddlZddlmZmZmZmZm Z defd„ƒYZ de fd„ƒYZ d„Z ed kr‘e ƒndS( sC Tkinter widgets for displaying multi-column listboxes and tables. iÿÿÿÿN(tFrametLabeltListboxt ScrollbartTkt MultiListboxcBsieZdZedddeddƒZeddddd d dd d d ƒZedddddddedddddeƒZd=id„Z d„Z d„Z d„Z ed„ƒZed„ƒZed„ƒZd„Zd„Zd„Zd=d=ed„Zid„Zd „Zid!„Zid"„Zd=d#„Zd$„Zd=d%„Zd&„Zd'„Zd(„Zd=d=d=d)„Z d=d=d=d*„Z!d=d=d=d+„Z"d,„Z#d-„Z$d.„Z%d/„Z&d0„Z'd1„Z(d2„Z)d3„Z*d4„Z+d5„Z,d6„Z-d7„Z.d8„Z/d9„Z0d:„Z1d;„Z2d<„Z3eZ4eZ5eZ6e.Z7e/Z8e$Z9e0Z:RS(>s¦ A multi-column listbox, where the current selection applies to an entire row. Based on the MultiListbox Tkinter widget recipe from the Python Cookbook (http://code.activestate.com/recipes/52266/) For the most part, ``MultiListbox`` methods delegate to its contained listboxes. For any methods that do not have docstrings, see ``Tkinter.Listbox`` for a description of what that method does. t backgrounds#888t takefocusthighlightthicknessit borderwidthtrelieftraisedtfontshelvetica -16 bolds#444t foregroundtwhitetselectborderwidthitexportselectiontselectbackgroundt activestyletnonec s-t|tƒr*tt|ƒƒ}t}nt}t|ƒdkrQtdƒ‚nt|ƒˆ_ gˆ_ gˆ_ |d#kr”dgt|ƒ}n't|ƒt|ƒkr»tdƒ‚n|ˆ_ tjˆ|ˆj�ˆjdddƒx²tˆj ƒD]¡\}}ˆj|d||ƒ|r‚tˆd|ˆj�} ˆj j| ƒ| jd|ddd d d dd dƒ|| _ntˆˆj�} ˆj j| ƒ| jd|ddd d d dd dƒ|| _| jd ˆjƒ| jdˆjƒ| jd‡fd†ƒ| jd‡fd†ƒ| jd‡fd†ƒ| jd‡fd†ƒ| jd‡fd†ƒ| jdd„ƒ| jd ˆjƒqýWˆjd ˆjƒˆjd‡fd†ƒˆjd‡fd†ƒˆjd‡fd †ƒˆjd!‡fd"†ƒˆj||�d#S($s/ Construct a new multi-column listbox widget. :param master: The widget that should contain the new multi-column listbox. :param columns: Specifies what columns should be included in the new multi-column listbox. If ``columns`` is an integer, the it is the number of columns to include. If it is a list, then its length indicates the number of columns to include; and each element of the list will be used as a label for the corresponding column. :param cnf, kw: Configuration parameters for this widget. Use ``label_*`` to configure all labels; and ``listbox_*`` to configure all listboxes. E.g.: >>> mlb = MultiListbox(master, 5, label_foreground='red') isExpected at least one columnis*Expected one column_weight for each columntweightttexttcolumntrowtstickytnewstpadxtpadys s s cs ˆjdƒS(Niÿÿÿÿ(t_scroll(te(tself(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt|ss csˆjd ƒS(Ni(R(R(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR}ss csˆj|jƒS(N(Rtdelta(R(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR~ss csˆj|j|jƒS(N(t scan_marktxty(R(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR€ss csˆj|j|jƒS(N(t scan_dragtoR"R#(R(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR�ss cSsdS(Ntbreak((R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR„sscsˆjddƒS(NR iÿÿÿÿ(tselect(R(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR�sscsˆjddƒS(NR i(R&(R(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRŽsscsˆjdˆjƒ ƒS(NR (R&t _pagesize(R(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR�sscsˆjdˆjƒƒS(NR (R&R'(R(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR�sN(t isinstancetinttlisttrangetFalsetTruetlent ValueErrorttuplet _column_namest _listboxest_labelstNonet_column_weightsRt__init__t FRAME_CONFIGtgrid_rowconfiguret enumeratetgrid_columnconfigureRt LABEL_CONFIGtappendtgridt column_indexRtLISTBOX_CONFIGtbindt_selectt_resize_columnt configure( Rtmastertcolumnstcolumn_weightstcnftkwtinclude_labelstitlabeltltlb((Rsa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR6;sT     ( ( cCs9|jjdƒrtSd|_|j|kr†xºt|jƒD]A\}}t|j|j ƒ|j ƒƒdkr>||_q>q>Wne|j|jj ƒdkr´|jj |_n7|jdkrë|jj dkrë|jj d|_n|jdk r1|jjd|j ƒ|jjd|j |jƒtStSdS( sô Callback used to resize a column of the table. Return ``True`` if the column is actually getting resized (if the user clicked on the far left or far right 5 pixels of a label); and ``False`` otherwies. si iiissN(twidgetR@R,R4t_resize_column_indexR9R2tabsR"twinfo_xt winfo_widthR>t_resize_column_motion_cbtnumt_resize_column_buttonrelease_cbR-(RteventRJRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRB™s"  )! cCsƒ|j|j}|jƒt|dƒ}|j|jjƒ}|jƒ|jƒ}td|dt|||ƒƒ|ds(RNtunbindRT(RRV((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRUÂscCs|jS(sh A tuple containing the names of the columns used by this multi-column listbox. (R1(R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt column_namesÊscCs t|jƒS(sÉ A tuple containing the ``Tkinter.Label`` widgets used to display the label of each column. If this multi-column listbox was created without labels, then this will be an empty tuple. These widgets will all be augmented with a ``column_index`` attribute, which can be used to determine which column they correspond to. This can be convenient, e.g., when defining callbacks for bound events. (R0R3(R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt column_labelsÒs cCs t|jƒS(sY A tuple containing the ``Tkinter.Listbox`` widgets used to display individual columns. These widgets will all be augmented with a ``column_index`` attribute, which can be used to determine which column they correspond to. This can be convenient, e.g., when defining callbacks for bound events. (R0R2(R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt listboxesßs cCsM|jj|jƒ}|jddƒ|j|ƒ|j|ƒ|jƒdS(Nitend(RNtnearestR#tselection_cleart selection_settactivatetfocus(RRRJ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRAîs   cCs(x!|jD]}|j|dƒq WdS(NtunitR%(R2t yview_scroll(RR RM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRõscCs&t|jdƒƒt|jdƒƒS(s2:return: The number of rows that makes up one pages @0,1000000s@0,0(R)tindex(R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR'úscCsÝ|dk r'|dk r'tdƒ‚n|dk rut|jƒƒdkrXd|}qut|jƒdƒ|}n|jddƒ|dk rÙtt|dƒ|jƒdƒ}|j |ƒ|rÙ|j |ƒqÙndS(sÒ Set the selected row. If ``index`` is specified, then select row ``index``. Otherwise, if ``delta`` is specified, then move the current selection by ``delta`` (negative numbers for up, positive numbers for down). This will not move the selection past the top or the bottom of the list. :param see: If true, then call ``self.see()`` with the newly selected index, to ensure that it is visible. s$specify index or delta, but not bothiiÿÿÿÿRaiN( R4R/R.t curselectionR)RctminRYtsizeRdtsee(RRiR Rm((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR&s    " cKstt|jƒƒt|jƒƒƒ}xÑt|jƒƒD]½\}}|jdƒse|jdƒr”x�|jD]}|ji||d6ƒqoWq;|jdƒs²|jdƒráxC|jD]}|ji||d6ƒq¼Wq;tj|i||6ƒq;WdS(s8 Configure this widget. Use ``label_*`` to configure all labels; and ``listbox_*`` to configure all listboxes. E.g.: >>> mlb = MultiListbox(master, 5) >>> mlb.configure(label_foreground='red') >>> mlb.configure(listbox_foreground='red') tlabel_slabel-itlistbox_slistbox-iN(tdictR*titemst startswithR3RCR2R(RRGRHtkeytvalRKtlistbox((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRC%s (cCs|ji||6ƒdS(s| Configure this widget. This is equivalent to ``self.configure({key,val``)}. See ``configure()``. N(RC(RRsRt((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt __setitem__9scKs+x$|jD]}|j|||�q WdS(sÇ Configure all table cells in the given row. Valid keyword arguments are: ``background``, ``bg``, ``foreground``, ``fg``, ``selectbackground``, ``selectforeground``. N(R2t itemconfigure(Rt row_indexRGRHRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt rowconfigure@scKs³|j|}tt|jƒƒt|jƒƒƒ}xwt|jƒƒD]c\}}|dkr—xHt|jƒƒD]}|j|i||6ƒqsWqH|ji||6ƒqHWdS( sÊ Configure all table cells in the given column. Valid keyword arguments are: ``background``, ``bg``, ``foreground``, ``fg``, ``selectbackground``, ``selectforeground``. RtbgR tfgRtselectforegroundN(s backgroundsbgs foregroundR{sselectbackgroundsselectforeground(R2RpR*RqR+RlRwRC(Rt col_indexRGRHRMRsRtRJ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pytcolumnconfigureHs ( cKs |j|}|j|||�S(sÑ Configure the table cell at the given row and column. Valid keyword arguments are: ``background``, ``bg``, ``foreground``, ``fg``, ``selectbackground``, ``selectforeground``. (R2Rw(RRxR}RGRHRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRwXs cGs~x8|D]0}t|ƒt|jƒkrtdƒ‚qqWx<t|jtt|ŒƒƒD]\}}|j||ŒqZWdS(s0 Insert the given row or rows into the table, at the given index. Each row value should be a tuple of cell values, one for each column in the row. Index may be an integer or any of the special strings (such as ``'end'``) accepted by ``Tkinter.Listbox``. sDrows should be tuples whose length is equal to the number of columnsN(R.R1R/tzipR2R*tinsert(RRitrowsteltRMtelts((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR€es  +cCs_g|jD]}|j||ƒ^q }|rQgt|ŒD]}t|ƒ^q;St|ƒSdS(s Return the value(s) of the specified row(s). If ``last`` is not specified, then return a single row value; otherwise, return a list of row values. Each row value is a tuple of cell values, one for each column in the row. N(R2tgetRR0(RtfirsttlastRMtvaluesR((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR„ts(#c Cs‚|jddd|ƒ\}}}}|j|j|ƒ\}}}} t|ƒt|ƒt|ƒt|ƒt|ƒt| ƒfS(sÇ Return the bounding box for the given table cell, relative to this widget's top-left corner. The bounding box is a tuple of integers ``(left, top, width, height)``. RiR(t grid_bboxR2tbboxR)( RRtcoltdxtdyt_R"R#twth((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR‰�s$"cCsE|jr|j|jƒn|j|jƒ|j|ddƒdS(s1 Hide the given column. The column's state is still maintained: its values will still be returned by ``get()``, and you must supply its values when calling ``insert()``. It is safe to call this on a column that is already hidden. :see: ``show_column()`` RiN(R3t grid_forgetR`R:(RR}((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt hide_column�s c CsŽ|j|}|jrH|j|jd|ddddddddƒn|j|jd|ddddddddƒ|j|d |ƒd S( s� Display a column that has been hidden using ``hide_column()``. It is safe to call this on a column that is not hidden. RRiRRRRiRN(R5R3R=R2R:(RR}R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt show_column�s  cCs)g|jD]}|j|||ƒ^q S(sK Add a binding to each ``Tkinter.Label`` widget in this mult-column listbox that will call ``func`` in response to the event sequence. :return: A list of the identifiers of replaced binding functions (if any), allowing for their deletion (to prevent a memory leak). (R_R@(RtsequencetfunctaddRK((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pytbind_to_labels®s cCs+x$|jD]}|j|||ƒq WdS(sM Add a binding to each ``Tkinter.Listbox`` widget in this mult-column listbox that will call ``func`` in response to the event sequence. :return: A list of the identifiers of replaced binding functions (if any), allowing for their deletion (to prevent a memory leak). N(R`R@(RR“R”R•Ru((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pytbind_to_listboxes»s cCs&|j|||ƒ|j|||ƒS(sc Add a binding to each ``Tkinter.Label`` and ``Tkinter.Listbox`` widget in this mult-column listbox that will call ``func`` in response to the event sequence. :return: A list of the identifiers of replaced binding functions (if any), allowing for their deletion (to prevent a memory leak). (R–R—(RR“R”R•((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pytbind_to_columnsÈs cOs|jdj||ŽS(Ni(R2Rj(Rtargstkwargs((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRjÚscOs|jdj||ŽS(Ni(R2tselection_includes(RR™Rš((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR›ÜscOs|jdj||ŽS(Ni(R2titemcget(RR™Rš((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRœÞscOs|jdj||ŽS(Ni(R2Rl(RR™Rš((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRlàscOs|jdj||ŽS(Ni(R2Ri(RR™Rš((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRiâscOs|jdj||ŽS(Ni(R2Rb(RR™Rš((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRbäscOs(x!|jD]}|j||Žq WdS(N(R2Re(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyReèscOs(x!|jD]}|j||Žq WdS(N(R2tdelete(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR�êscOs(x!|jD]}|j||Žq WdS(N(R2R!(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR!ìscOs(x!|jD]}|j||Žq WdS(N(R2R$(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR$îscOs(x!|jD]}|j||Žq WdS(N(R2Rm(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRmðscOs(x!|jD]}|j||Žq WdS(N(R2tselection_anchor(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRžòscOs(x!|jD]}|j||Žq WdS(N(R2Rc(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRcôscOs(x!|jD]}|j||Žq WdS(N(R2Rd(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRdöscOs*x#|jD]}|j||Ž}q W|S(N(R2tyview(RR™RšRMtv((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRŸøscOs(x!|jD]}|j||Žq WdS(N(R2t yview_moveto(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR¡ûscOs(x!|jD]}|j||Žq WdS(N(R2Rh(RR™RšRM((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRhýsN(;t__name__t __module__t__doc__RpR-R7R;R,R?R4R6RBRSRUtpropertyR^R_R`RARR'R&RCRvRyR~RwR€R„R‰R‘R’R–R—R˜RjR›RœRlRiRbReR�R!R$RmRžRcRdRŸR¡Rht itemconfigt rowconfigt columnconfigt select_anchort select_cleartselect_includest select_set(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRs|     ^     #                           tTablecBs¯eZdZd#d#eed#id„Zd„Zd„Zd„Zd#d#d#d„Z id„Z id„Z d#d„Z d#d#d#d „Z d#d#d#d „Zd#d#d#d „Ze Ze Ze Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„ƒZd„Zd„Zd„Z d„Z!d#d#ed„Z"dd„Z#d„Z$ed„Z%d„Z&d#e'd „Z(e'e'd!„Z)e'Z*d"„Z+RS($sÌ A display widget for a table of values, based on a ``MultiListbox`` widget. For many purposes, ``Table`` can be treated as a list-of-lists. E.g., table[i] is a list of the values for row i; and table.append(row) adds a new row with the given lits of values. Individual cells can be accessed using table[i,j], which refers to the j-th column of the i-th row. This can be used to both read and write values from the table. E.g.: >>> table[i,j] = 'hello' The column (j) can be given either as an index number, or as a column name. E.g., the following prints the value in the 3rd row for the 'First Name' column: >>> print(table[3, 'First Name']) John You can configure the colors for individual rows, columns, or cells using ``rowconfig()``, ``columnconfig()``, and ``itemconfig()``. The color configuration for each row will be preserved if the table is modified; however, when new rows are added, any color configurations that have been made for *columns* will not be applied to the new row. Note: Although ``Table`` acts like a widget in some ways (e.g., it defines ``grid()``, ``pack()``, and ``bind()``), it is not itself a widget; it just contains one. This is because widgets need to define ``__getitem__()``, ``__setitem__()``, and ``__nonzero__()`` in a way that's incompatible with the fact that ``Table`` behaves as a list-of-lists. :ivar _mlb: The multi-column listbox used to display this table's data. :ivar _rows: A list-of-lists used to hold the cell values of this table. Each element of _rows is a row value, i.e., a list of cell values, one for each column in the row. c Ks¡t|ƒ|_||_t|ƒ|_td„t|ƒDƒƒ|_|dkr^g|_ n/g|D]} g| D] } | ^qr^qe|_ x|j D]} |j | ƒq—Wt |j|||| �|_ |j j dddtddƒ|rKt|jddd |j jƒ} | j|j jd d <| j dd dd ƒ| |_nd|_|r“x6t|j jƒD]\} }|jd|jƒqmWn|jƒdS(så Construct a new Table widget. :type master: Tkinter.Widget :param master: The widget that should contain the new table. :type column_names: list(str) :param column_names: A list of names for the columns; these names will be used to create labels for each column; and can be used as an index when reading or writing cell values from the table. :type rows: list(list) :param rows: A list of row values used to initialze the table. Each row value should be a tuple of cell values, one for each column in the row. :type scrollbar: bool :param scrollbar: If true, then create a scrollbar for the new table widget. :type click_to_sort: bool :param click_to_sort: If true, then create bindings that will sort the table's rows by a given column's values if the user clicks on that colum's label. :type reprfunc: function :param reprfunc: If specified, then use this function to convert each table cell value to a string suitable for display. ``reprfunc`` has the following signature: reprfunc(row_index, col_index, cell_value) -> str (Note that the column is specified by index, not by name.) :param cnf, kw: Configuration parameters for this widget's contained ``MultiListbox``. See ``MultiListbox.__init__()`` for details. css!|]\}}||fVqdS(N((t.0RJtc((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pys dstsidetlefttexpandtfilltbothtorienttverticaltcommandityscrollcommandtrightR#s N(R.t _num_columnst _reprfuncRt_frameRpR9t_column_name_to_indexR4t_rowst _checkrowRt_mlbtpackR-RRŸtsetR`t _scrollbart_sortkeyR_R@t_sortt _fill_table(RRDR^R�RFt scrollbart click_to_sorttreprfuncRGRHRR tsbRJRL((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR6=s0#   /   cOs|jj||ŽdS(srPosition this table's main frame widget in its parent widget. See ``Tkinter.Frame.pack()`` for more info.N(R¼RÁ(RR™Rš((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRÁ‰scOs|jj||ŽdS(srPosition this table's main frame widget in its parent widget. See ``Tkinter.Frame.grid()`` for more info.N(R¼R=(RR™Rš((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR=ŽscCs|jjƒdS(s-Direct (keyboard) input foxus to this widget.N(RÀRf(R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRf“scCs|jj|||ƒdS(skAdd a binding to this table's main frame that will call ``func`` in response to the event sequence.N(RÀR@(RR“R”R•((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR@—scKs|jj|||�dS(s%:see: ``MultiListbox.rowconfigure()``N(RÀRy(RRxRGRH((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRyœscKs)|j|ƒ}|jj|||�dS(s(:see: ``MultiListbox.columnconfigure()``N(R>RÀR~(RR}RGRH((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR~ scKs(|j|ƒ}|jj||||�S(s&:see: ``MultiListbox.itemconfigure()``(R>RÀRw(RRxR}RGRH((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRw¥scCs|jj|||ƒS(s':see: ``MultiListbox.bind_to_labels()``(RÀR–(RR“R”R•((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR–ªscCs|jj|||ƒS(s*:see: ``MultiListbox.bind_to_listboxes()``(RÀR—(RR“R”R•((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR—®scCs|jj|||ƒS(s(:see: ``MultiListbox.bind_to_columns()``(RÀR˜(RR“R”R•((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR˜²scCs“|j|ƒ|jj||ƒ|jdk rfgt|ƒD]!\}}|j|||ƒ^q<}n|jj||ƒ|jr�|jƒndS(sT Insert a new row into the table, so that its row index will be ``row_index``. If the table contains any rows whose row index is greater than or equal to ``row_index``, then they will be shifted down. :param rowvalue: A tuple of cell values, one for each column in the new row. N( R¿R¾R€R»R4R9RÀt_DEBUGt_check_table_vs_mlb(RRxtrowvaluetjR ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR€¾s 4 cCs8x|D]}|j|ƒqW|jr4|jƒndS(sî Add new rows at the end of the table. :param rowvalues: A list of row values used to initialze the table. Each row value should be a tuple of cell values, one for each column in the row. N(R<RËRÌ(Rt rowvaluesRÍ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pytextendÐs  cCs3|jt|jƒ|ƒ|jr/|jƒndS(sš Add a new row to the end of the table. :param rowvalue: A tuple of cell values, one for each column in the new row. N(R€R.R¾RËRÌ(RRÍ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR<Ûs cCs6g|_|jjddƒ|jr2|jƒndS(s0 Delete all rows in this table. iRaN(R¾RÀR�RËRÌ(R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pytclearås  cCstt|tƒrtdƒ‚nRt|tƒr_t|ƒdkr_|j|d|j|dƒSt|j|ƒSdS(s‹ Return the value of a row or a cell in this table. If ``index`` is an integer, then the row value for the ``index``th row. This row value consists of a tuple of cell values, one for each column in the row. If ``index`` is a tuple of two integers, ``(i,j)``, then return the value of the cell in the ``i``th row and the ``j``th column. sSlicing not supportediiiN(R(tsliceR/R0R.R¾R>(RRi((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt __getitem__ís ! cCsœt|tƒrtdƒ‚nzt|tƒrìt|ƒdkrì|d|j|dƒ}}|j|gƒ}||j||<|jdk r§|j|||ƒ}n|j j |j ||ƒ|j j |j |dƒ|j|ƒn¬|j|gƒ}|j|ƒt|ƒ|j|<|jdk rdgt|ƒD]!\}}|j|||ƒ^q:}n|j j ||ƒ|j j |dƒ|j|ƒdS(sú Replace the value of a row or a cell in this table with ``val``. If ``index`` is an integer, then ``val`` should be a row value (i.e., a tuple of cell values, one for each column). In this case, the values of the ``index``th row of the table will be replaced with the values in ``val``. If ``index`` is a tuple of integers, ``(i,j)``, then replace the value of the cell in the ``i``th row and ``j``th column with ``val``. sSlicing not supportediiiN(R(RÒR/R0R.R>t_save_config_infoR¾R»R4RÀR`R€R�t_restore_config_infoR¿R*R9(RRiRtRJRÎt config_cookieR ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRvýs&! 7cCs‚tttƒrtdƒ‚nt|tƒrNt|ƒdkrNtdƒ‚n|j|=|jj|ƒ|j r~|j ƒndS(sA Delete the ``row_index``th row from this table. sSlicing not supportedisCannot delete a single cell!N( R(RiRÒR/R0R.R¾RÀR�RËRÌ(RRx((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt __delitem__%s!  cCs t|jƒS(s< :return: the number of rows in this table. (R.R¾(R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt__len__1scCs>t|ƒ|jkr:td|t|ƒ|jfƒ‚ndS(s‹ Helper function: check that a given row value has the correct number of elements; and if not, raise an exception. s"Row %r has %d columns; expected %dN(R.RºR/(RRÍ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR¿7scCs |jjS(s1A list of the names of the columns in this table.(RÀR^(R((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR^DscCsAt|tƒr2d|ko)|jknr2|S|j|SdS(sö If ``i`` is a valid column index integer, then return it as is. Otherwise, check if ``i`` is used as the name for any column; if so, return that column's index. Otherwise, raise a ``KeyError`` exception. iN(R(R)RºR½(RRJ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR>Is.cCs|jj|j|ƒƒdS(s$:see: ``MultiListbox.hide_column()``N(RÀR‘R>(RR>((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR‘VscCs|jj|j|ƒƒdS(s$:see: ``MultiListbox.show_column()``N(RÀR’R>(RR>((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR’ZscCs+|jjƒ}|r#t|dƒSdSdS(s³ Return the index of the currently selected row, or None if no row is selected. To get the row value itself, use ``table[table.selected_row()]``. iN(RÀRjR)R4(Rtsel((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt selected_rowbscCs|jj|||ƒdS(s:see: ``MultiListbox.select()``N(RÀR&(RRiR Rm((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR&lsttogglecCsÕ|d krtdƒ‚n|j|ƒ}|jdtƒ}|dkrg||jkrg|jjƒn1|jjdtj |ƒd|dkƒ||_|j ƒ|j |dtdtƒ|j rÑ|j ƒnd S( sÒ Sort the rows in this table, using the specified column's values as a sort key. :param column_index: Specifies which column to sort, using either a column index (int) or a column's label name (str). :param order: Specifies whether to sort the values in ascending or descending order: - ``'ascending'``: Sort from least to greatest. - ``'descending'``: Sort from greatest to least. - ``'toggle'``: If the most recent call to ``sort_by()`` sorted the table by the same column (``column_index``), then reverse the rows; otherwise sort in ascending order. t ascendingt descendingRÛsBsort_by(): order should be "ascending", "descending", or "toggle".t index_by_idRstreverseRmN(RÜRÝRÛ(R/R>RÔR-RÄR¾Rßtsorttoperatort itemgetterRÆRÕRËRÌ(RR>torderRÖ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pytsort_byts     cCs7|jj}|jj|ƒr"dS|j|ƒdSdS(sLEvent handler for clicking on a column label -- sort by that column.tcontinueN(RNR>RÀRBRä(RRVR>((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRÅšs   cCs�|jjddƒxvt|jƒD]e\}}|jdk rugt|ƒD]!\}}|j|||ƒ^qK}n|jjd|ƒq#WdS(s„ Re-draw the table from scratch, by clearing out the table's multi-column listbox; and then filling it in with values from ``self._rows``. Note that any cell-, row-, or column-specific color configuration that has been done will be lost. The selection will also be lost -- i.e., no row will be selected after this call completes. iRaN(RÀR�R9R¾R»R4R€(Rt save_configRJRRÎR ((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRÆ­s 7cs t‡‡‡fd†dDƒƒS(Nc3s1|]'}|ˆjjˆˆ|ƒdfVqdS(iÿÿÿÿN(RÀR¦(R®tk(R¯trR(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pys ½sR R|RR(s foregroundsselectforegrounds backgroundsselectbackground(Rp(RRèR¯((R¯RèRsa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt_get_itemconfig¼scs©|dkr*tttˆjƒƒƒ}nˆjƒ}|r^|dk r^tˆj|ƒ}n|rƒt‡fd†|Dƒƒ}nt‡fd†|Dƒƒ}||fS(s* Return a 'cookie' containing information about which row is selected, and what color configurations have been applied. this information can the be re-applied to the table (after making modifications) using ``_restore_config_info()``. Color configuration information will be saved for any rows in ``row_indices``, or in the entire table, if ``row_indices=None``. If ``index_by_id=True``, the the cookie will associate rows with their configuration information based on the rows' python id. This is useful when performing operations that re-arrange the rows (e.g. ``sort``). If ``index_by_id=False``, then it is assumed that all rows will be in the same order when ``_restore_config_info()`` is called. c3sP|]F}tˆj|ƒgtˆjƒD]}ˆj||ƒ^q)fVqdS(N(tidR¾R+RºRé(R®RèR¯(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pys Ûsc3sC|]9}|gtˆjƒD]}ˆj||ƒ^qfVqdS(N(R+RºRé(R®RèR¯(R(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pys ßsN(R4R*R+R.R¾RÚRêRp(Rt row_indicesRÞt selectiontconfig((Rsa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRÔÁs   c CsG|\}}|dkr.|jjddƒn|rÕx t|jƒD]Š\}}t|ƒ|kr£x>t|jƒD]*}|jj|||t|ƒ|ƒqrWnt|ƒ|krD|jj |d|ƒqDqDWnn|dk rú|jj |d|ƒnxF|D]>}x5t|jƒD]$}|jj|||||ƒqWqWdS(sy Restore selection & color configuration information that was saved using ``_save_config_info``. iRaRmN( R4RÀRcR9R¾RêR+RºRwR&( RtcookieRÞRmRìRíRèRR¯((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRÕæs  +   cCs x2|jjD]$}t|ƒ|jƒks t‚q Wx)|D]!}t|ƒ|jks<t‚q<W|jt|jjƒks‚t‚x€t|ƒD]r\}}xct|ƒD]U\}}|jdk rÛ|j|||ƒ}n|jj |ƒ||ks¨t‚q¨Wq�WdS(s Verify that the contents of the table's ``_rows`` variable match the contents of its multi-listbox (``_mlb``). This is just included for debugging purposes, to make sure that the list-modifying operations are working correctly. N( RÀR`R.RltAssertionErrorRºR^R9R»R4R„(RRŠRRJRÎtcell((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyRÌs" !N(,R¢R£R¤R4R-R6RÁR=RfR@RyR~RwR–R—R˜R§R¨R¦R€RÐR<RÑRÓRvR×RØR¿R¥R^R>R‘R’RÚR&RäRÅRÆRéR,RÔRÕRËRÌ(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR­sR%I          (      &   %c stƒ‰ˆjd‡fd†ƒtˆdjƒdddddgdd„ƒ}|jd td d ƒd d lm}d dlm}xÑt t |j ƒd ƒƒD]³\}}|ddkrÇq¥n|j ƒ}x‚|j |ƒD]q}|jƒdgd}|jƒdgd}|j|t|ddƒt|ddƒt|ddƒgƒqãWq¥W|jdddƒ|jdddƒ|jdddƒ|jdddƒx`tt|ƒƒD]L}xCd D];} ||| fdkrÈ|j|| ddddƒqÈqÈWq»WˆjƒdS(!Ns cs ˆjƒS(N(tdestroy(R(troot(sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR"ssWord Synset Hypernym HyponymRFiiRÉcSsd|S(Ns %s((RJRÎts((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyR&sR²R³R´iÿÿÿÿ(twordnet(tbrowniôtNtt definitions*none*tWordRs#afatSynsets#efetHypernyms#feetHyponyms#ffeR s#666R|(RûRü(RR@R­tsplitRÁR-t nltk.corpusRôRõtsortedRÂt tagged_wordstlowertsynsetst hypernymsthyponymsR<tgetattrR¨R+R.R¦tmainloop( ttableRôRõtwordtpostsynsetthyperthypoRR((Ròsa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pytdemo s:  )   t__main__(R¤t nltk.compattnltkRáttkinterRRRRRRtobjectR­R R¢(((sa/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/nltk/nltk/draw/table.pyt s  (ÿÿÿÿ !