By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,942 Members | 1,788 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,942 IT Pros & Developers. It's quick & easy.

a simple question... how to detect click action in another module?

P: n/a
Hello!

How to detect in Python that some click action was performed in some module
imported by my main module?
Let's assume I have a tree.py module that implements all functionality of a
tree view widget and my sample application (let's say myapp.py) that imports
those tree module to create tree view control inside the main frame. I want
in my application to have some method that responds immediately (!!!!) to
click action performed within the tree module.... So if the click action is
performed in the tree module, some method from my myapp.py module
immediately executes... it could be for example a method that just displays
currently selected item of a tree (on a status bar) or whatever.....

Any hints would be appreciated.

Thank You in advance!

Please forgive me any english mistakes ;-)

Best Regards,

Sylwia
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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/Coo.../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

Jul 18 '05 #2

P: n/a

Uzytkownik "Brian Kelley" <bk*****@wi.mit.edu> napisal
If you could be more specific about what GUI you are using, we could
give you a more specific answer.


Oh, I forgot to add that I use Tkinter!
Anyway you helped me very much!!!! The link to the 'recipe' describing how
to implement the observer pattern in Python was great!!!
Thanks to You I solved my problem!
Thanks!!!

Best Regards,

Sylwia

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.