Skip to content

Tkdnd mouse cursor handling patch #43699

Description

@klappnase
mannequin
BPO 1525806
Nosy @loewis
Files
  • patch_Tkdnd.diff: against 18168
  • Tkdnd.diff: against 66717
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/loewis'
    closed_at = None
    created_at = <Date 2006-07-20.10:28:26.000>
    labels = ['type-feature', 'expert-tkinter', '3.9', '3.10']
    title = 'Tkdnd mouse cursor handling patch'
    updated_at = <Date 2020-11-18.19:52:20.961>
    user = 'https://bugs.python.org/klappnase'

    bugs.python.org fields:

    activity = <Date 2020-11-18.19:52:20.961>
    actor = 'iritkatriel'
    assignee = 'loewis'
    closed = False
    closed_date = None
    closer = None
    components = ['Tkinter']
    creation = <Date 2006-07-20.10:28:26.000>
    creator = 'klappnase'
    dependencies = []
    files = ['7415', '13750']
    hgrepos = []
    issue_num = 1525806
    keywords = ['patch']
    message_count = 3.0
    messages = ['50723', '86347', '86369']
    nosy_count = 4.0
    nosy_names = ['loewis', 'klappnase', 'gpolo', 'flupke']
    pr_nums = []
    priority = 'low'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1525806'
    versions = ['Python 3.9', 'Python 3.10']

    Linked PRs

    Activity

    1. klappnase commented on Jul 20, 2006

      klappnasemannequin
      MannequinAuthor

      This patch improves two things I always found annoying
      with Tkdnd.
      First, it is not possible to change the default cursor
      ("hand2") that is used for drag and drop operations,
      second, this cursor always shows up on <ButtonPress>
      events and not on <Motion> events, as I think it should.
      This has the ugly effect that if for example you use
      Tkdnd to drag items from a Listbox, each time the user
      selects a new item from the Listbox, the "hand2" cursor
      pops up.

      To fix the first issue I added a "dndcursor" option to
      the dnd_start() function, which defaults to "hand2" to
      keep the "classic" behavior intact.
      Second I added a self.dndcursor attribute to the
      DnDHandler class that stores this dndcursor's value;
      then I moved the call that actually changes the
      widget's cursor into the DnDHandler.on_motion() method
      to make sure that this cursor only shows when actually
      some drag occurs. self.dndcursor is set to None then,
      to avoid multiple calls to "widget['cursor'] == ...". I
      know that this is a slight change to the original
      behavior, however I doubt that anyone will miss it.

      Regards

      Michael

    2. gpolo commented on Apr 23, 2009

      gpolomannequin
      Mannequin

      I just created a sample listbox with drag & drop support and it indeed
      looks better if the "hand2" cursor or whatever cursor is set only shows
      up when motion starts. But, for the sample included with Tkdnd, I find
      it better to show up the different cursor when clicking the canvas item
      instead of waiting to starting move it.
      Are you willing to adjust that ?

      The first feature added -- to support custom cursor is fine, just this
      second change needs to be rethought.

    3. added
      type-featureA feature request or enhancement
      and removed
      type-bugAn unexpected behavior, bug, or error
      on Apr 23, 2009
    4. klappnase commented on Apr 23, 2009

      klappnasemannequin
      MannequinAuthor

      Maybe this depends on whether the dragged item is "clickable" like
      listbox items and buttons or not , like the Labels in the Tkdnd demo.
      Ok, I wrote a second patch that solves this by adding another option to
      dnd_start(); if this option is set to True (the default) the user gets
      the classic behavior, if set to False the cursor changes when the motion
      starts, as in the initial patch. I couldn't figure out a good name for
      this option, so I called it "swapcursoronclick", at least the name says
      what it is for ^_^

    5. transferred this issue fromon Apr 10, 2022
    6. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Nov 23, 2023
    7. added a commit that references this issue on Jul 5, 2026
    8. added
      3.16new features, bugs and security fixes
      and removed on Jul 5, 2026
    9. serhiy-storchaka commented on Jul 5, 2026

      @serhiy-storchaka
      Member

      #152371 fixes the cursor flash on a plain click: the drag cursor is now deferred until the pointer moves past a small threshold, matching BWidget's drag-and-drop.

      Leaving this open for the configurable-cursor question. Note that an application can already show its own cursor from the drop-target callbacks, e.g.:

      def dnd_enter(self, source, event):
          self.widget['cursor'] = 'plus'   # show a custom drop cursor
          ...
      
      def dnd_leave(self, source, event):
          self.widget['cursor'] = ''       # restore it
          ...
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.16new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions