a simple question... how to detect click action in another module?
Brian Kelley
bkelley at wi.mit.edu
Sun Feb 15 17:16:03 EST 2004
Ringwraith wrote:
> Hello!
>
> How to detect in Python that some click action was performed in some module
> imported by my main module?
What you are talking about is an observer pattern. Most GUI widgets
supply an EVENT mechanism that when triggered call a python function.
This event mechanism will be dependent upon your GUI toolkit. I'm
assuming that you are using a GUI, otherwise you can roll your own event
mechanism or just use an existing one:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/131499
The basic Tkinter example is here, notice the frame.bind call:
http://effbot.org/zone/tkinter-events-and-bindings.htm
wxpython has a full tree example in their demo, just install wxpython
from http://wxpython.org/ and run the demo application. Examining the
source code will tell you how to capture wxpython tree-click events.
If you could be more specific about what GUI you are using, we could
give you a more specific answer.
Brian Kelley
More information about the Python-list
mailing list