Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
tkinter.dnd.DndHandler Class Reference

List of all members.

Public Member Functions

def __init__
def __del__
def on_motion
def on_release
def cancel
def finish

Public Attributes

 source
 target
 initial_button
 initial_widget
 release_pattern
 save_cursor

Static Public Attributes

 root = None

Detailed Description

Definition at line 118 of file dnd.py.


Constructor & Destructor Documentation

def tkinter.dnd.DndHandler.__init__ (   self,
  source,
  event 
)

Definition at line 122 of file dnd.py.

00122 
00123     def __init__(self, source, event):
00124         if event.num > 5:
00125             return
00126         root = event.widget._root()
00127         try:
00128             root.__dnd
00129             return # Don't start recursive dnd
00130         except AttributeError:
00131             root.__dnd = self
00132             self.root = root
00133         self.source = source
00134         self.target = None
00135         self.initial_button = button = event.num
00136         self.initial_widget = widget = event.widget
00137         self.release_pattern = "<B%d-ButtonRelease-%d>" % (button, button)
00138         self.save_cursor = widget['cursor'] or ""
00139         widget.bind(self.release_pattern, self.on_release)
00140         widget.bind("<Motion>", self.on_motion)
00141         widget['cursor'] = "hand2"

Here is the caller graph for this function:

Definition at line 142 of file dnd.py.

00142 
00143     def __del__(self):
00144         root = self.root
00145         self.root = None
00146         if root:
00147             try:
00148                 del root.__dnd
00149             except AttributeError:
00150                 pass


Member Function Documentation

def tkinter.dnd.DndHandler.cancel (   self,
  event = None 
)

Definition at line 181 of file dnd.py.

00181 
00182     def cancel(self, event=None):
00183         self.finish(event, 0)

Here is the call graph for this function:

Here is the caller graph for this function:

def tkinter.dnd.DndHandler.finish (   self,
  event,
  commit = 0 
)

Definition at line 184 of file dnd.py.

00184 
00185     def finish(self, event, commit=0):
00186         target = self.target
00187         source = self.source
00188         widget = self.initial_widget
00189         root = self.root
00190         try:
00191             del root.__dnd
00192             self.initial_widget.unbind(self.release_pattern)
00193             self.initial_widget.unbind("<Motion>")
00194             widget['cursor'] = self.save_cursor
00195             self.target = self.source = self.initial_widget = self.root = None
00196             if target:
00197                 if commit:
00198                     target.dnd_commit(source, event)
00199                 else:
00200                     target.dnd_leave(source, event)
00201         finally:
00202             source.dnd_end(target, event)
00203 
00204 
00205 
00206 # ----------------------------------------------------------------------
00207 # The rest is here for testing and demonstration purposes only!

Here is the caller graph for this function:

def tkinter.dnd.DndHandler.on_motion (   self,
  event 
)

Definition at line 151 of file dnd.py.

00151 
00152     def on_motion(self, event):
00153         x, y = event.x_root, event.y_root
00154         target_widget = self.initial_widget.winfo_containing(x, y)
00155         source = self.source
00156         new_target = None
00157         while target_widget:
00158             try:
00159                 attr = target_widget.dnd_accept
00160             except AttributeError:
00161                 pass
00162             else:
00163                 new_target = attr(source, event)
00164                 if new_target:
00165                     break
00166             target_widget = target_widget.master
00167         old_target = self.target
00168         if old_target is new_target:
00169             if old_target:
00170                 old_target.dnd_motion(source, event)
00171         else:
00172             if old_target:
00173                 self.target = None
00174                 old_target.dnd_leave(source, event)
00175             if new_target:
00176                 new_target.dnd_enter(source, event)
00177                 self.target = new_target

def tkinter.dnd.DndHandler.on_release (   self,
  event 
)

Definition at line 178 of file dnd.py.

00178 
00179     def on_release(self, event):
00180         self.finish(event, 1)

Here is the call graph for this function:


Member Data Documentation

Definition at line 134 of file dnd.py.

Definition at line 135 of file dnd.py.

Definition at line 136 of file dnd.py.

tkinter.dnd.DndHandler.root = None [static]

Definition at line 120 of file dnd.py.

Definition at line 137 of file dnd.py.

Definition at line 132 of file dnd.py.

Definition at line 133 of file dnd.py.


The documentation for this class was generated from the following file: