JL idZddlmZmZmZddlmZmZmZm Z m Z m Z ddl m Z ddlmZGddeZdZe e fd ZGd d eZGd d ZdZdZedk(reyy)z Graphically display a Tree. )IntVarMenuTk) BoxWidget CanvasFrame CanvasWidget OvalWidget ParenWidget TextWidget)Tree)in_idleceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZy)TreeSegmentWidgeta A canvas widget that displays a single segment of a hierarchical tree. Each ``TreeSegmentWidget`` connects a single "node widget" to a sequence of zero or more "subtree widgets". By default, the bottom of the node is connected to the top of each subtree by a single line. However, if the ``roof`` attribute is set, then a single triangular "roof" will connect the node to all of its children. Attributes: - ``roof``: What sort of connection to draw between the node and its subtrees. If ``roof`` is true, draw a single triangular "roof" over the subtrees. If ``roof`` is false, draw a line between each subtree and the node. Default value is false. - ``xspace``: The amount of horizontal space to leave between subtrees when managing this widget. Default value is 10. - ``yspace``: The amount of space to place between the node and its children when managing this widget. Default value is 15. - ``color``: The color of the lines connecting the node to its subtrees; and of the outline of the triangular roof. Default value is ``'#006060'``. - ``fill``: The fill color for the triangular roof. Default value is ``''`` (no fill). - ``width``: The width of the lines connecting the node to its subtrees; and of the outline of the triangular roof. Default value is 1. - ``orientation``: Determines whether the tree branches downwards or rightwards. Possible values are ``'horizontal'`` and ``'vertical'``. The default value is ``'vertical'`` (i.e., branch downwards). - ``draggable``: whether the widget can be dragged by the user. c ||_||_d|_d|_d|_d|_d|_|Dcgc]}|jdddddc}|_|jddddd |_ |j||D]}|j|d|_ tj||fi|y cc}w) zI :type node: :type subtrees: list(CanvasWidgetI) r F#006060fillhidden)rstateoutlineN)_label _subtrees _horizontal_roof_xspace_yspace_ordered create_line_linescreate_polygon_polygon_add_child_widget _managingr__init__)selfcanvaslabelsubtreesattribscsubtrees T/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/nltk/draw/tree.pyr'zTreeSegmentWidget.__init__@s  !    PXX!v))!Q19)EX -- qr9.  u% ,G  " "7 + ,dF6g6YsB>c^|j}|dk(r||_|jrB|jD]}|j|d|j|jdy|jD]}|j|d|j|jdy|dk(r%|dk(rd|_y|dk(rd |_yt d |d k(rB|jD]}|j|| |j|j| yt|tr7|d d k(r/|jt|d}|j|| y|dk(r|j|j| y|dk(rD|j|j||i|jD]}|j|||iy|dvr5|dk(r||_ n |dk(r||_ |j|jy|dk(r||_ytj |||y)Nroofr)rnormal orientation horizontalverticalrz*orientation must be horizontal or verticalcolorr)rrwidth)xspaceyspacer9r:ordered)r)rr" itemconfigr$r ValueError isinstancetupleintrrupdaterr r __setitem__)r(attrvaluer)ls r/rBzTreeSegmentWidget.__setitem___s 6>DJzz9A%%ax%89!!$--x!@9A%%ax%89!!$--x!@ ] " $#$ *$#$  !MNN W_[[ 1!!!%!0 1   dmmU  ; e $aG); CQL)A   ae  , V^   dmm%  8 W_   dmmdE] ;[[ 4!!!dE]3 4 ) )x$ !$ KK $ Y !DM  $ $T4 7c>|dk(r |jS|dk(r*|jj|j|S|dk(r*|jj|jdSt |t rC|ddk(r;|j t|d}|jj|dS|dk(r |jS|d k(r |jS|d k(r|jry y |d k(r |jStj||S)Nr1r8r7rrr5rr9r:r3r4r6r;)rr)itemcgetr$r>r?r"r@rrrr r __getitem__)r(rCrEs r/rIzTreeSegmentWidget.__getitem__s 6>::  W_;;=))$--> > W_;;=))$--C C e $aG); CQL)A;;=))!V4 4 X <<  X <<  ] "#! Y == ++D$7 7rFc|jSN)rr(s r/r*zTreeSegmentWidget.labels {{rFc |jddSrK)rrLs r/r+zTreeSegmentWidget.subtreess~~a  rFc|j|j|j|||_|j|jy)z2 Set the node label to ``label``. N)_remove_child_widgetrr%rA)r(r*s r/ set_labelzTreeSegmentWidget.set_labels; !!$++. u%  DKK rFc|jj|}||j|<|j||j||j |y)zC Replace the child ``oldchild`` with ``newchild``. N)rindexrOr%rA)r(oldchildnewchildrRs r/ replace_childzTreeSegmentWidget.replace_childsN$$X. (u !!(+ x( HrFc|jj|}|j|=|j||jj |j j |j|jyrK) rrRrOr)deleter"poprAr)r(childrRs r/ remove_childzTreeSegmentWidget.remove_childs_$$U+ NN5 ! !!%( T[[__./ DKK rFc |j}|jj|||j||jj |j ddddd|j|jy)Nrrr) r)rinsertr%r"appendr!rAr)r(rRrYr)s r/ insert_childzTreeSegmentWidget.insert_childsg eU+ u% 6--aAqy-IJ DKK rFcL|jr |jgS|jSrK)rr$r"rLs r/_tagszTreeSegmentWidget._tagss ::MM? ";; rFct|tr|jj}n|j}|jr|d|d|dzdz fS|d|dzdz |dfS)Nrr5@)r>rr*bboxr)r(rYres r/ _subtree_topzTreeSegmentWidget._subtree_topsw e. /;;=%%'D::>!#4#9#9#; tT4~~ab) &G<<>DtT!W%DtT!W%DtT!W%DtT!W%D  &    KKM  ueT4tUE  KKM  ueT4tUE  # IG!..0NUE;;t~~33G<=D#'#4#4W#= Xx KKM ueXx H  IrFc^|jr|j|S|j|SrK)r_maintain_order_horizontal_maintain_order_vertical)r(rYs r/rkz!TreeSegmentWidget._maintain_order s-   2259 9007 7rFc|j\}}}}||jurg|jD]L}|j\}}} } ||jz|kDs+|j d||jz|z N|jS|g} |jj |} ||j z} t| dzt|jD]}|j|j\}}} } | |kDs+|j|j | |z d| | |z |j zz } | j|j|||j z } t| dz ddD]}|j|j\}}} } | | ks+|j|j | | z d| | |z |j zz} | j|j||jj\}}} } | ||jz kDr8|jj d||jz | z |j} | S)Nrr5) rerrrmoverRrrangerjr])r(rYlefttoprightbotr.x1y1x2y2movedrRxis r/r|z*TreeSegmentWidget._maintain_order_verticals<"'**,sE3 DKK >> =#*<<> RR%*LLC$,,$6$;< = >> !GENN((/E $A519c$..&9: 4#'>>!#4#9#9#; RRr6NN1%**1r615b4<<//ALL!23  4t||#A519b"- 4#'>>!#4#9#9#; RRr6NN1%**1r615b4<<//ALL!23  4 ${{//1 RRC$,,&&   C$,,$6$;< rFc|j\}}}}||jurf|jD]K}|j\}}} } ||jz|kDs+|j ||jz|z M|jS|g} |jj |} ||j z} t| dzt|jD]}|j|j\}}} } | |kDs+|j|j d| |z | | |z |j zz } | j|j|||j z } t| dz ddD]}|j|j\}}} } | | ks+|j|j d| | z | | |z |j zz} | j|j||jj\}}} } | ||jz kDr8|jj ||jz | z d|j} | S)Nr5rr~) rerrrrrRrrrjr])r(rYrrrrr.rrrrrrRyrs r/r{z,TreeSegmentWidget._maintain_order_horizontal<s:"'**,sE3 DKK >> <#*<<> RR4<<'",LL!5!:; < >> !GENN((/Edll"A519c$..&9: 4#'>>!#4#9#9#; RRr6NN1%**1a"f5b4<<//ALL!23  4dll"A519b"- 4#'>>!#4#9#9#; RRr6NN1%**1a"f5b4<<//ALL!23  4 ${{//1 RRD4<<''    !4r!91= rFc|j\}}d}|jD]\}|j}||dz |jz}||dz }|j ||||d|dz |j zz }^d}|jD]}||j |dz }|t|jz}|jD]}|j d||z y)Nrr5rb)rhrrerrrrfrj) r(rprqrr. subtree_bboxdxdycenters r/_manage_horizontalz$TreeSegmentWidget._manage_horizontalfs**, ~~ BG"<<>La(4<<7B\!_$B LLR a<?2T\\A AA  B~~ 4G d''03 3F 4#dnn%%~~ ,G LLEFN + ,rFc|j\}}d}|jD]\}|j}||dz |jz}||dz }|j ||||d|dz |j zz }^d}|jD]/}||j |dt|jz z }1|jD]}|j ||z dy)Nrr5rdr)rhrrerrrrfrj) r(rprqrr.rrrrs r/_manage_verticalz"TreeSegmentWidget._manage_vertical|s**, ~~ BG"<<>La(4<<7B\!_$B LLR a<?2T\\A AA  B~~ JG d''03c$..6II IF J~~ ,G LL + ,rFcd|_|j\}}t|jdk(ry|jr|j n|j |jD]}|j|d|_y)NTrF)r&rhrjrrrrry)r(rprqr.s r/_managezTreeSegmentWidget._managesz**, t~~ ! #      # # %  ! ! #~~ "G LL ! "rFc<d|jd|jdS)Nz [TreeSeg z: ])rrrLs r/__repr__zTreeSegmentWidget.__repr__s 4;;-r$..)9;;rFN)__name__ __module__ __qualname____doc__r'rBrIr*r+rPrUrZr^r`rfrhryrkr|r{rrrrrFr/rrsqB7>*8X80!!!! 88'IR8 (T(T,,,*"r r*_tree_to_treesegr) r)t make_node make_leaf tree_attribs node_attribs leaf_attribs loc_attribsr*rYr+s r/rrs!T&!'')<|<        !ILII3l33  sA c i}i}i}i}t|jD]V\} } | dddk(r | || dd<| dddk(r | || dd<(| dddk(r | || dd<9| dddk(r | || dd<Jtd| zt||||||||S) aS Convert a Tree into a ``TreeSegmentWidget``. :param make_node: A ``CanvasWidget`` constructor or a function that creates ``CanvasWidgets``. ``make_node`` is used to convert the Tree's nodes into ``CanvasWidgets``. If no constructor is specified, then ``TextWidget`` will be used. :param make_leaf: A ``CanvasWidget`` constructor or a function that creates ``CanvasWidgets``. ``make_leaf`` is used to convert the Tree's leafs into ``CanvasWidgets``. If no constructor is specified, then ``TextWidget`` will be used. :param attribs: Attributes for the canvas widgets that make up the returned ``TreeSegmentWidget``. Any attribute beginning with ``'tree_'`` will be passed to all ``TreeSegmentWidgets`` (with the ``'tree_'`` prefix removed. Any attribute beginning with ``'node_'`` will be passed to all nodes. Any attribute beginning with ``'leaf_'`` will be passed to all leaves. And any attribute beginning with ``'loc_'`` will be passed to all text locations (for Trees). Ntree_node_leaf_loc_zBad attribute: %s)listitemsr=r) r)rrrr,rrrrkeyrDs r/tree_to_treesegmentrs0LLLK7==?+ 8 U r7g $)LQR ! !W $)LQR ! !W $)LQR ! !W #(KAB 0367 7 8    rFceZdZdZeefdZdZdZddZddZ ddZ ddZ dd Z dd Z d Zd Zd ZdZdZdZdZy) TreeWidgeta A canvas widget that displays a single Tree. ``TreeWidget`` manages a group of ``TreeSegmentWidgets`` that are used to display a Tree. Attributes: - ``node_attr``: Sets the attribute ``attr`` on all of the node widgets for this ``TreeWidget``. - ``node_attr``: Sets the attribute ``attr`` on all of the leaf widgets for this ``TreeWidget``. - ``loc_attr``: Sets the attribute ``attr`` on all of the location widgets for this ``TreeWidget`` (if it was built from a Tree). Note that a location widget is a ``TextWidget``. - ``xspace``: The amount of horizontal space to leave between subtrees when managing this widget. Default value is 10. - ``yspace``: The amount of space to place between the node and its children when managing this widget. Default value is 15. - ``line_color``: The color of the lines connecting each expanded node to its subtrees. - ``roof_color``: The color of the outline of the triangular roof for collapsed trees. - ``roof_fill``: The fill color for the triangular roof for collapsed trees. - ``width`` - ``orientation``: Determines whether the tree branches downwards or rightwards. Possible values are ``'horizontal'`` and ``'vertical'``. The default value is ``'vertical'`` (i.e., branch downwards). - ``shapeable``: whether the subtrees can be independently dragged by the user. THIS property simply sets the ``DRAGGABLE`` property on all of the ``TreeWidget``'s tree segments. - ``draggable``: whether the widget can be dragged by the user. c ||_||_||_i|_i|_ddi|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_i|_i|_i|_g|_g|_|j)||d |j+||d |_|j/|j,t1j2||fi|y) Nr7z#008000z#008080r5z#c0c0c0Frr6r) _make_node _make_leaf_tree _nodeattribs _leafattribs _locattribs _line_color _line_width _roof_color _roof_fill _shapeablerr _orientationr _keys_expanded_trees_collapsed_trees_nodes_leaves_make_collapsed_trees_make_expanded_tree_treesegr%rr')r(r)rrrr,s r/r'zTreeWidget.__init__&s$# #Y/$$#  &  ! "   ""61b100B?  t}}-dF6g6rFc |j|SaF Return the ``TreeSegmentWidget`` for the specified subtree. :param path_to_tree: A list of indices i1, i2, ..., in, where the desired widget is the widget corresponding to ``tree.children()[i1].children()[i2]....children()[in]``. For the root, the path is ``()``. )rr( path_to_trees r/ expanded_treezTreeWidget.expanded_treeIs##L11rFc |j|Sr)rrs r/collapsed_treezTreeWidget.collapsed_treeTs$$\22rFct|jjD]}|j||t|jjD]}|j||yz5 Add a binding to all tree segments. N)rrvalues bind_clickrr(callbackbuttontsegs r/bind_click_treeszTreeWidget.bind_click_trees_sf--4467 .D OOHf - ...5578 .D OOHf - .rFct|jjD]}|j||t|jjD]}|j||yr)rrr bind_dragrrs r/bind_drag_treeszTreeWidget.bind_drag_treeshsf--4467 -D NN8V , -..5578 -D NN8V , -rFc|jD]}|j|||jD]}|j||yz. Add a binding to all leaves. N)rrr(rrleafs r/bind_click_leaveszTreeWidget.bind_click_leavesqsFLL .D OOHf - .LL .D OOHf - .rFc|jD]}|j|||jD]}|j||yr)rrrs r/bind_drag_leaveszTreeWidget.bind_drag_leaveszsFLL -D NN8V , -LL -D NN8V , -rFc|jD]}|j|||jD]}|j||yz- Add a binding to all nodes. N)rrr(rrnodes r/bind_click_nodeszTreeWidget.bind_click_nodessFKK .D OOHf - .KK .D OOHf - .rFc|jD]}|j|||jD]}|j||yr)rrrs r/bind_drag_nodeszTreeWidget.bind_drag_nodessFKK -D NN8V , -KK -D NN8V , -rFc t|tsy|j}|j}|||j fi|j }|j j||jDcgc]}|||fi|j}}|xj|z c_ t|||d|j|j|j} | |j|<||j | <| j#t%t'|D]} || } |j)|| || fz ycc}w)Nr5)r1r7rr8)r>r rrr*rrr]leavesrrrrrrrrhiderrjr) r(r)rrrrrrErtreesegrrYs r/rz TreeWidget._make_collapsed_treess#!T" OO OO @d.?.?@ 4 EFXXZP)FA;):):;PP  #   """" &-c"! 7 s1v BAaDE  & &vucQDj A B%Qs9D?c 6|j}|j}t|tr|||j fi|j }|j j||}tt|Dcgc]}|j|||||fz} }t||| |j|j} | |j|<||j| <| S|||fi|j } |j"j| | Scc}w)N)r7r8)rrr>r r*rrr]rrjrrrrrrrr) r(r)rrrrrchildrenrr+rrs r/rzTreeWidget._make_expanded_treesOO OO a VQWWYD$2C2CDD KK  t $Hs8}-((!cQDjIH(hd.>.>dFVFVG)0D  %"%DJJw NVQ<$*;*;!Dcv|dddk(r|jD] }|||dd< y|dddk(r|jD] }|||dd< y|dk(r5||_t|jj D]}||d< y|dk(rb||_t|jj D]}||d< t|jj D]}||d< y|dk(r5||_t|jj D]}||d< y|d k(r5||_ t|jj D]}||d < y|d k(rx||_ t|jj D]}||d < t|jj D]}||d < |jD]}||d < y|d k(rr||_ t|jj D]}||d < t|jj D]}||d < |jy|dk(rr||_ t|jj D]}||d< t|jj D]}||d< |jy|dk(rr||_t|jj D]}||d< t|jj D]}||d< |jy|dk(rb||_t|jj D]}||d< t|jj D]}||d< yt!j"|||y)Nrrr line_colorr7 line_widthr8 roof_color roof_fillr shapeable draggabler9r:r3r;)rrrrrrrrrrrrmanagerrr rrB)r(rCrDrrrs r/rBzTreeWidget.__setitem__s 8w   '!&T!"X ' "1X   '!&T!"X ' \ !$D T1188:; & %W  & \ !$D T1188:; & %W  &T2299;< & %W  & \ !$D T2299;< & %W  & [ #DOT2299;< %$V  % [ #DOT1188:; *$)[! *T2299;< *$)[! *  *$)[! * X  DLT1188:; '!&X 'T2299;< '!&X ' KKM X  DLT1188:; '!&X 'T2299;< '!&X ' KKM ] " %D T1188:; ,&+]# ,T2299;< ,&+]# , KKM Y !DMT1188:; ("'Y (T2299;< ("'Y (  $ $T4 7rFc(|dddk(r|jj|dddS|dddk(r|jj|dddS|dddk(r|jj|dddS|dk(r |jS|dk(r |j S|dk(r |j S|d k(r |jS|d k(r |jS|d k(r |jS|d k(r |jS|d k(r |jStj||S)Nrrrrrrrrrrr9r:r3)rgetrrrrrrrrrrrrI)r(rCs r/rIzTreeWidget.__getitem__ s4 8w $$((ab48 8 "1X $$((ab48 8 "1X ##''QR$7 7 \ !## # \ !## # \ !## # [ ?? " [ ?? " X <<  X <<  ] "$$ $++D$7 7rFcgSrKrrLs r/r`zTreeWidget._tags#s rFc"t|jjt|jjz}|D]C}|j s|j |j |jEyrK)rrrrrshowrr)r(segsrs r/rzTreeWidget._manage&snD((//12T  ! ! ( ( *6   D{{}    rFcz|}|dr|j|j|}n|j|j|}|j|ur*|j ||j |||_n |jj|||j|jjdd\}}|jjdd\}}|j||z ||z |j|jj|y)z) Collapse/expand a tree. r1Nrd)rrrparentrOr%rrUrr*rerrrA)r(r old_treeseg new_treesegnewxnewyoldxoldys r/toggle_collapsedzTreeWidget.toggle_collapsed0s# v ..tzz+/FGK// ;0GHK    4 '  % %k 2  " "; /'DM    . .{K H "((*//1"15 t"((*//1"15 tdTk2  ##K0rFN)r5)rrrrr r'rrrrrrrrrrrBrIr`rr rrFr/rrsb&R$.!7F 2 3.-.-.-B<.=8~841rFrc0eZdZdZdZdZdZdZdZy)TreeViewc hddlm}m}||_t |_|j j d|j jd|j|j jd|jt|j x}|_ |j jd|jjt|j |_ |jjdd|jj d f}d|jj f}t!||t#||_g|_t)t#|D]q}t+|j-|||d d d d d d| }|j/|j0|j&j3||j5|dds|j7|jj9dd|j;y)Nr)ceilsqrtNLTKz z z helveticaboldz#008040z#004080z#004040whiter5) node_font leaf_color node_colorrrrr leaf_fontboth)expandr)mathrr_treesr_toptitlebinddestroyr_cframe print_to_filer_sizesetrr@rj_width_widgetsrrr)rr r] add_widget_layoutpack _init_menubar) r(treesrrcfrhelvrwidgets r/r'zTreeView.__init__Vs# D   }dll3 }dll3' 22T\ }dll&@&@ADII&  rdjjnn..7djjnn../$tCJ/01  s5z" (A a$$$!$ F  # #F$;$; < MM  ( MM&!Q ' ("  0 rFcpdx}x}x}}|j}tt|jD]}|j|}|j dd\}}||zdk(r|}d}|j ||z ||z |j ddz}t ||j ddz}y)Nrrdrrb)r%rrjr&rerrm) r(rrrrur8r.rr s r/r(zTreeView._layoutsAD s4==)* 4A]]1%F!;;=!,LT45yA~ KKD!d( + a 2%AtV[[]1-23D 4rFct|j}t|d}|jdd|jjd|jdd|j d|j d d| t|d}|jd |jdd |j |jd|jdd|j |jd|jdd|j |jd|jdd|j |jd|jdd|j |j dd| |jj|y)Nr)tearoffzPrint to PostscriptzCtrl-p)r* underlinecommand acceleratorExitr5zCtrl-xFile)r*r2menuTinyr)r*variabler2rDr3SmallrMediumLargeHuge2Zoom)r7) rr add_commandr!r"r  add_cascadeadd_radiobuttonr#resizeconfig)r(menubarfilemenuzoommenus r/r*zTreeView._init_menubarstyy/+'LL..  At||   &AHE+  ZZKK !    ZZKK !    ZZKK !    ZZKK !    ZZKK !  &AHE g&rFcd|jj df}d|jj f}|jj}|jj}|jD]a}||d<||d<||d<||d<|jjdkrd|d <:|jjd krd |d <]d |d <c|jy) Nrrrrr9r:rr5rrdrb)r#rr&r()r(err-r9r:r.s r/rEzTreeView.resizesdjjnn..7djjnn../!!mm )F"&F; "&F; %F8 %F8 zz~~"$'(|$!B&'(|$'(|$ ) rFc`|jy|jjd|_yrK)rr )r(rLs r/r zTreeView.destroys& 99    rFcRtry|jj|i|y)z Enter the Tkinter mainloop. This function must be called if this demo is created from a non-interactive program (e.g. from a secript); otherwise, the demo will close as soon as the script completes. N)r rmainloop)r(argskwargss r/rOzTreeView.mainloops% 9  D+F+rFN) rrrr'r(r*rEr rOrrFr/r r Us")V 45'n$ ,rFr c0t|jy)zd Open a new window containing a graphical diagram of the given trees. :rtype: None N)r rO)r+s r/ draw_treesrSs e rFc &ddlfd}tddd}tjd}t |j |dd d d d d d }|j |ddd}d}tjd}t |j |||d}fd}fd} |j|j|j|j|j|d|jdj| d|jj| dt|j |} |j | |jddzdtjd} t|j | d dd} d| d<|j | d|jddzd} d}t|j |j!}t#|j |d d}|j || jddz|jddztjd}t |j |dddd d!d"#}|j%|j || jddz|jddz|j| |j|jd|j'y)$Nrc6djddz|d<y)N#%06dri?Brrandint)cwrandoms r/rzdemo..fillsv~~a886 rFi&ird)r8height closeenoughzU (S (NP the very big cat) (VP (Adv sorta) (V saw) (NP (Det the) (N dog))))r5)rir)ritalicrblackgreen4blue2)rrrrrrrrc:d}t|t|||dS)N)rir)fontgreenr)rr )r)textbigs r/boxitzdemo..boxits(FDs!C'RRrFc2t|t||dS)Ncyanr)r r )r)res r/ovalitzdemo..ovalits&*VT":HHrFz/(S (NP this tree) (VP (V is) (AdjP shapeable))))rc6djddz|d<y)Nz#%04d00r'r7rW)rrZs r/r7zdemo..colors!FNN1d$;;W rFcdjddz|jd<d|jjd<y)NrVrrlrrr7)rXr*rY)rrZs r/color2zdemo..color2!s<")FNN1d,C"C +2 (rFrbzb (S (NP this tree) (AUX was) (VP (V built) (PP (P with) (NP (N tree_to_treesegment)))))) tree_color tree_xspace tree_widthrc>|ddk(r|jddjdjd|jddjdjd|jdjdjd|jjdjdd|d<y|jddjdjd|jddjdjd|jdjdjd|jjdjdd|d<y)Nr3r4r5rr6rb)rr+set_textr) treewidgets r/ orientswitchzdemo..orientswitch9s_ m $ 4  $ $Q * 3 3 5a 8 A A* M  % %a + 4 4 6q 9 B B: N  % %a ( 1 1 3A 6 ? ? K  % % ' 0 0 21 5 > >z J(2J} %  $ $Q * 3 3 5a 8 A A, O  % %a + 4 4 6q 9 B B< P  % %a ( 1 1 3A 6 ? ? M  % % ' 0 0 21 5 > >| L(4J} %rFaM Try clicking, right clicking, and dragging different elements of each of the trees. The top-left tree is a TreeWidget built from a Tree. The top-right is a TreeWidget built from a Tree, using non-default widget constructors for the nodes & leaves (BoxWidget and OvalWidget). The bottom-left tree is built from tree_to_treesegment.)rrz/(S (NP this tree) (VP (V is) (Adj horizontal)))brown2)rr]rbrown4r4)rrrrrr3)rZrr fromstringrr)r'rr rrrr rerr striprrrO)rr,rtcrgrjtreetoktc2r7rnparentree3tc3ruretwidgettextboxtree4tc4rZs @r/demors9 3s :B  ; A   ,. BMM"b"SIooOPG RYY['5&A FC<3++,--.q!a##FA.""61-  S )EMM%1*B/ OO E E  UxQ1 CC MM#r2779Q<",- 5 #Ddjjl3G W7aHGMM'388:a=2-sxxz!}r/AB OOM NE   ,  CJJLMM#sxxz!}r)7<<>!+rs%$E< E

$z1rP1P1p Q,Q,h l^ zFrF