diff options
Diffstat (limited to 'devdocs/python~3.12/library%2Ftkinter.dnd.html')
| -rw-r--r-- | devdocs/python~3.12/library%2Ftkinter.dnd.html | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Ftkinter.dnd.html b/devdocs/python~3.12/library%2Ftkinter.dnd.html new file mode 100644 index 00000000..db26161a --- /dev/null +++ b/devdocs/python~3.12/library%2Ftkinter.dnd.html @@ -0,0 +1,26 @@ + <span id="tkinter-dnd-drag-and-drop-support"></span><h1>tkinter.dnd — Drag and drop support</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/tkinter/dnd.py">Lib/tkinter/dnd.py</a></p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>This is experimental and due to be deprecated when it is replaced with the Tk DND.</p> </div> <p>The <a class="reference internal" href="#module-tkinter.dnd" title="tkinter.dnd: Tkinter drag-and-drop interface (Tk)"><code>tkinter.dnd</code></a> module provides drag-and-drop support for objects within a single application, within the same window or between windows. To enable an object to be dragged, you must create an event binding for it that starts the drag-and-drop process. Typically, you bind a ButtonPress event to a callback function that you write (see <a class="reference internal" href="tkinter#bindings-and-events"><span class="std std-ref">Bindings and Events</span></a>). The function should call <a class="reference internal" href="#tkinter.dnd.dnd_start" title="tkinter.dnd.dnd_start"><code>dnd_start()</code></a>, where ‘source’ is the object to be dragged, and ‘event’ is the event that invoked the call (the argument to your callback function).</p> <p>Selection of a target object occurs as follows:</p> <ol class="arabic simple"> <li>Top-down search of area under mouse for target widget</li> </ol> <ul class="simple"> <li>Target widget should have a callable <em>dnd_accept</em> attribute</li> <li>If <em>dnd_accept</em> is not present or returns None, search moves to parent widget</li> <li>If no target widget is found, then the target object is None</li> </ul> <ol class="arabic simple" start="2"> <li>Call to <em><old_target>.dnd_leave(source, event)</em> +</li> <li>Call to <em><new_target>.dnd_enter(source, event)</em> +</li> <li>Call to <em><target>.dnd_commit(source, event)</em> to notify of drop</li> <li>Call to <em><source>.dnd_end(target, event)</em> to signal end of drag-and-drop</li> </ol> <dl class="py class"> <dt class="sig sig-object py" id="tkinter.dnd.DndHandler"> +<code>class tkinter.dnd.DndHandler(source, event)</code> </dt> <dd> +<p>The <em>DndHandler</em> class handles drag-and-drop events tracking Motion and ButtonRelease events on the root of the event widget.</p> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.dnd.DndHandler.cancel"> +<code>cancel(event=None)</code> </dt> <dd> +<p>Cancel the drag-and-drop process.</p> </dd> +</dl> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.dnd.DndHandler.finish"> +<code>finish(event, commit=0)</code> </dt> <dd> +<p>Execute end of drag-and-drop functions.</p> </dd> +</dl> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.dnd.DndHandler.on_motion"> +<code>on_motion(event)</code> </dt> <dd> +<p>Inspect area below mouse for target objects while drag is performed.</p> </dd> +</dl> <dl class="py method"> <dt class="sig sig-object py" id="tkinter.dnd.DndHandler.on_release"> +<code>on_release(event)</code> </dt> <dd> +<p>Signal end of drag when the release pattern is triggered.</p> </dd> +</dl> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="tkinter.dnd.dnd_start"> +<code>tkinter.dnd.dnd_start(source, event)</code> </dt> <dd> +<p>Factory function for drag-and-drop process.</p> </dd> +</dl> <div class="admonition seealso"> <p class="admonition-title">See also</p> <p><a class="reference internal" href="tkinter#bindings-and-events"><span class="std std-ref">Bindings and Events</span></a></p> </div> <div class="_attribution"> + <p class="_attribution-p"> + © 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br> + <a href="https://docs.python.org/3.12/library/tkinter.dnd.html" class="_attribution-link">https://docs.python.org/3.12/library/tkinter.dnd.html</a> + </p> +</div> |
