rL i.nddlmZmZmZmZGddZGddeZGddZGdd Zy ) )_api backend_toolscbookwidgetsceZdZdZddZy) ToolEventz)Event for tool manipulation (add/remove).Nc<||_||_||_||_yN)namesendertooldata)selfr r r rs a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/backend_managers.py__init__zToolEvent.__init__s    r __name__ __module__ __qualname____doc__rrrrrs 3rrc$eZdZdZdfd ZxZS)ToolTriggerEventz/Event to inform that a tool has been triggered.c8t|||||||_yr )superr canvasevent)rr r r rr __class__s rrzToolTriggerEvent.__init__s vtT2&r)NN)rrrrr __classcell__)rs@rrr s9''rrceZdZdZdZy)ToolManagerMessageEventzs Event carrying messages from toolmanager. Messages usually get displayed to the user by the toolbar. c.||_||_||_yr )r r message)rr r r#s rrz ToolManagerMessageEvent.__init__s   rNrrrrr!r!s  rr!ceZdZdZddZedZedZejdZddZ dZ d Z dd Z ed Z d Zd ZdZdZdZdZddZdZedZddZy) ToolManagera Manager for actions triggered by user interactions (key press, toolbar clicks, ...) on a Figure. Attributes ---------- figure : `.Figure` keypresslock : `~matplotlib.widgets.LockDraw` `.LockDraw` object to know if the `canvas` key_press_event is locked. messagelock : `~matplotlib.widgets.LockDraw` `.LockDraw` object to know if the message is available to write. Ncd|_i|_i|_i|_t j |_tj|_ tj|_ d|_ |j|yr ) _key_press_handler_id_tools_keys_toggledrCallbackRegistry _callbacksrLockDraw keypresslock messagelock_figure set_figurerfigures rrzToolManager.__init__.sf%)"   002$,,."++-  rcH|jsy|jjS)z Canvas managed by FigureManager.N)r0canvasrs rr5zToolManager.canvas>s||||"""rc|jS)zFigure that holds the canvas.)r0r6s rr3zToolManager.figureEs||rc&|j|yr )r1r2s rr3zToolManager.figureJs rc |jr%|jj|j||_|r+|jj d|j |_|r'|j jD] }||_ yy)z Bind the given figure to the tools. Parameters ---------- figure : `.Figure` update_tools : bool, default: True Force tools to update figure. key_press_eventN) r'r5mpl_disconnectr0 mpl_connect _key_pressr(valuesr3)rr3 update_toolsr s rr1zToolManager.set_figureNsz  % % KK & &t'A'A B )-)@)@!4??*4D &  **, %$  % rc:|jj||S)a Connect event with string *s* to *func*. Parameters ---------- s : str The name of the event. The following events are recognized: - 'tool_message_event' - 'tool_removed_event' - 'tool_added_event' For every tool added a new event is created - 'tool_trigger_TOOLNAME', where TOOLNAME is the id of the tool. func : callable Callback function for the toolmanager event with signature:: def func(event: ToolEvent) -> Any Returns ------- cid The callback id for the connection. This can be used in `.toolmanager_disconnect`. )r,connect)rsfuncs rtoolmanager_connectzToolManager.toolmanager_connectbs8&&q$//rc8|jj|S)z Disconnect callback id *cid*. Example usage:: cid = toolmanager.toolmanager_connect('tool_trigger_zoom', onpress) #...later toolmanager.toolmanager_disconnect(cid) )r, disconnect)rcids rtoolmanager_disconnectz"ToolManager.toolmanager_disconnects))#..rcb||}d}t|||}|jj||y)z!Emit a `ToolManagerMessageEvent`.Ntool_message_event)r!r,process)rr#r rBevents r message_eventzToolManager.message_events3 >F '67; 5)rc|jS)zCurrently toggled tools.)r*r6s r active_togglezToolManager.active_toggles}}rcv|jjDcgc] \}}||k(s |}}}|Scc}}w)a Return the keymap associated with the specified tool. Parameters ---------- name : str Name of the Tool. Returns ------- list of str List of keys associated with the tool. )r)items)rr kikeyss rget_tool_keymapzToolManager.get_tool_keymaps8#jj..0>daAI>> ?s 55cJ|j|D]}|j|=yr )rUr))rr rRs r _remove_keyszToolManager._remove_keyss'%%d+ A 1  rc "||jvrt|d|j|t|tr|g}|D]J}||j vr+t jd|d|j |d|||j |<Ly)z Set the keymap to associate with the specified tool. Parameters ---------- name : str Name of the Tool. key : str or list of str Keys to associate with the tool. z not in ToolszKey z changed from z to N)r(KeyErrorrW isinstancestrr)r warn_external)rr keyrRs r update_keymapzToolManager.update_keymaps t{{ "dX]34 4 $ c3 %C !ADJJ""1#^DJJqM?$tfEG DJJqM  !rc|j|}t|ddr|j|d|j|t d||}|j j |j||j|=y)z Remove tool named *name*. Parameters ---------- name : str Name of the tool. toggledF toolmanagertool_removed_eventN) get_toolgetattr trigger_toolrWrr,rKr r()rr r rLs r remove_toolzToolManager.remove_toolso}}T" 4E *   dM 2 $.d;  E2 KK rc2tjt|j|}|st dt |z||j vr$tjd|j |S|||g|i|}||j |<|j|j||jt|tjrv|j%|jjdt!n&|jj|jd|j"r|j%|dd|j'|j(t+d||}|j,j/|j0||S)a Add *tool* to `ToolManager`. If successful, adds a new event ``tool_trigger_{name}`` where ``{name}`` is the *name* of the tool; the event is fired every time the tool is triggered. Parameters ---------- name : str Name of the tool, treated as the ID, has to be unique. tool : type Class of the tool to be added. A subclass will be used instead if one was registered for the current canvas class. *args, **kwargs Passed to the *tool*'s constructor. See Also -------- matplotlib.backend_tools.ToolBase : The base class for tools. zImpossible to find class for %sz;A "Tool class" with the same name already exists, not addedNtool_added_event)r_find_tool_classtyper5 ValueErrorr[r(rr\default_keymapr^rZToolToggleBase radio_groupr* setdefaultsetr`_handle_toggler1r3rr,rKr )rr r argskwargstool_clstool_objrLs radd_toolzToolManager.add_toolsV.!11$t{{2CTJ>TJK K 4;;     3 4;;t$ $D$888$ D  " " .   tX%<%< = h < < =##+ ((su5 (()=)=tD##HdD9DKK(,dH=  E2rc|j}|m|j|jdvr)|jdj|jy|jdj |jy|j||jk(rd}nI|j| |j}n-|j |j|||||j}||j|<y)aO Toggle tools, need to untoggle prior to using other Toggle tool. Called from trigger_tool. Parameters ---------- tool : `.ToolBase` canvasevent : Event Original Canvas event or None. data : object Extra data to pass to the tool when triggering. N)rnr r*removeaddre)rr rrrnr`s rrqzToolManager._handle_toggles&&   yyDMM$// d#**4995  d#'' 2  == % 2G]]; ' /iiG   dmmK8")" $iiG&- k"rc|j|}|y||}t|tjr|j ||||j |||d|z}t |||||}|jj||y)a Trigger a tool and emit the ``tool_trigger_{name}`` event. Parameters ---------- name : str Name of the tool. sender : object Object that wishes to trigger the tool. canvasevent : Event Original Canvas event or None. data : object Extra data to pass to the tool when triggering. Nztool_trigger_%s) rcrZrrmrqtriggerrr,rK)rr r rrr rBrLs rrezToolManager.trigger_tool;s}}T" <  >F dM88 9   k4 8 V[$/  $ FD+tD 5)rc|j|jjry|jj |jd}|y|j ||y)N)r)r]r.lockedr)getre)rrLr s rr=zToolManager._key_pressZsS 99  1 1 8 8 : zz~~eii. <  $E2rc|jS)z,A dict mapping tool name -> controlled tool.)r(r6s rtoolszToolManager.toolscs{{rct|tjr|j|jvr|S||jvr|rt j d|y|j|S)a Return the tool object with the given name. For convenience, this passes tool objects through. Parameters ---------- name : str or `.ToolBase` Name of the tool, or the tool itself. warn : bool, default: True Whether a warning should be emitted it no tool with the given name exists. Returns ------- `.ToolBase` or None The tool or None if no tool with the given name exists. z"ToolManager does not control tool N)rZrToolBaser r(rr\)rr warns rrczToolManager.get_toolhsc& t]33 4II,K t{{ """8AC{{4  rr )T)NNN)rrrrrpropertyr5r3setterr1rDrHrMrOrUrWr^rfrvrqrer=rrcrrrr%r% s  ##  ]]  %(0< /*$!,"7r)-V*>3!rr%N) matplotlibrrrrrrr!r%rrrrs7::'y'  c!c!r