Python (2.*) Tkinter - Advanced Event Handling Formatting
<p>I'm writing a test program to detect mouse motion within a Tkinter Window using Python 2.*. I can create the necessary widgets and bind the appropriate event handler function to the root widget as needed:</p>

<pre><code>import Tkinter as tk

class App:

   def __init__(self, master=None):
      self.root = master
      self.frame = tk.Frame(master)
      self.frame.pack()
      self.create_widgets()
      self.setup_handlers()

   def create_widgets(self):
      ...

   def setup_handlers(self):
      self.root.bind('&lt;Motion&gt;', self.update)   # This is the line I wish to look at

   def update(self, event):
      ...

root = tk.Tk()
app = App(master=root)
root.mainloop()
</code></pre>

<p>What I want to do now is be able to activate the event handler with a combined input. I want to be able, for instance, to only activate the event handler when I move the mouse with the 'r' key held down. What event string would I need for this? Where can I find a full rundown on the event-string formatting for binding event handlers?</p>

<p>for the combined event handling, you can do something like:</p>

<pre><code>class App:
  holding = False
  def __init__(self, master):
    self.root = master
    self.root.bind("&lt;KeyPress&gt;", self.holdkey)
    self.root.bind("&lt;KeyRelease&gt;", self.releasekey)

  def holdkey(self, e):
    if e.char == "r" and not self.holding:
      self.root.bind("&lt;Motion&gt;", self.combined_update)
      self.holding = True

  def releasekey(self, e):
    if e.char == "r" and self.holding:
      self.root.unbind("&lt;Motion&gt;")
      self.holding = False

  def combined_update(self, e):
    # Event handling for the combined event.
    print ("yo")
</code></pre>

<p>This will "probably" work.</p>

python tkinter event-handling