• Home
  • Raw
  • Download

Lines Matching +full:where +full:- +full:object

1 """Drag-and-drop support for Tkinter.
6 I am trying to make this as generic as possible -- not dependent on
10 To enable an object to be dragged, you must create an event binding
11 for it that starts the drag-and-drop process. Typically, you should
13 should call Tkdnd.dnd_start(source, event), where 'source' is the
14 object to be dragged, and 'event' is the event that invoked the call
16 instantiation, the returned instance should not be stored -- it will
17 be kept alive automatically for the duration of the drag-and-drop.
19 When a drag-and-drop is already in process for the Tk interpreter, the
24 The object is *not* necessarily a widget -- it can be any
25 application-specific object that is meaningful to potential
26 drag-and-drop targets.
28 Potential drag-and-drop targets are discovered as follows. Whenever
29 the mouse moves, and at the start and end of a drag-and-drop move, the
31 widget (not to be confused with the target object, yet to be
33 object. If there is a target widget, and it has an attribute
34 dnd_accept, this should be a function (or any callable object). The
35 function is called as dnd_accept(source, event), where 'source' is the
36 object being dragged (the object passed to dnd_start() above), and
37 'event' is the most recent event object (generally a <Motion> event;
40 object. If dnd_accept() returns None, or if the target widget has no
42 target widget, and the search for a target object is repeated from
45 object, there is no target object (the target object is None).
47 The target object thus produced, if any, is called the new target
48 object. It is compared with the old target object (or None, if there
50 source object, and 'event' is the most recent event object):
52 - Both the old and new target objects are None. Nothing happens.
54 - The old and new target objects are the same object. Its method
57 - The old target object was None, and the new target object is not
58 None. The new target object's method dnd_enter(source, event) is
61 - The new target object is None, and the old target object is not
62 None. The old target object's method dnd_leave(source, event) is
65 - The old and new target objects differ and neither is None. The old
66 target object's method dnd_leave(source, event), and then the new
67 target object's method dnd_enter(source, event) is called.
69 Once this is done, the new target object replaces the old one, and the
74 The drag-and-drop processes can end in two ways: a final target object
75 is selected, or no final target object is selected. When a final
76 target object is selected, it will always have been notified of the
83 If no final target object is selected, and there was an old target
84 object, its dnd_leave(source, event) method is called to complete the
87 Finally, the source object is notified that the drag-and-drop process
89 the selected target object, or None if no target object was selected.
90 The source object can use this to implement the commit action; this is
96 sequence by calling the cancel() method on the object returned by
136 self.release_pattern = "<B%d-ButtonRelease-%d>" % (button, button)
205 # ----------------------------------------------------------------------
242 # where the pointer is relative to the label widget:
245 # where the widget is relative to the canvas:
249 x, y = self.where(self.canvas, event)
255 def where(self, canvas, event): member in Icon
256 # where the corner of the canvas is relative to the screen:
259 # where the pointer is relative to the canvas widget:
260 x = event.x_root - x_org
261 y = event.y_root - y_org
263 return x - self.x_off, y - self.y_off
281 x, y = source.where(self.canvas, event)
283 dx, dy = x2-x1, y2-y1
288 x, y = source.where(self.canvas, event)
290 self.canvas.move(self.dndid, x-x1, y-y1)
299 x, y = source.where(self.canvas, event)