473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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
2 1504
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is...
13
by: LRW | last post by:
Having a problem getting a onSubmit function to work, to where it popsup a confirmation depending on which radiobutton is selected. Here's what I have: function checkdel() { if...
6
by: joebob | last post by:
I've got two forms, Form1 and Form2. Form1 opens invisibly when the database opens. From Form1 (or from a regular module or class module accessed by Form1), is there a way to detect when Form2...
2
by: RSH | last post by:
Hi, i have a situation where I have a VB .Net Module built that contains all of the functions I need. I now need to add a form to the project and i need the form to sdisplay and the module code...
4
by: Martin Horn | last post by:
Hi, I would be grateful if someone can advise me on the following problem I have encountered. I have created a test project to demonstrate the problem, it has 2 forms: Form1, with one...
2
by: khng | last post by:
When there is a HTML Form with lots of input elements, how can I know which element is triggering the form submit action with the help of javascript.
3
by: John Wright | last post by:
How can I set the property of a loaded Assembly using reflection. My Shell program will log in a person and retrieve a list of all programs the person can use. When the shell program launches a...
6
by: Terry Holland | last post by:
I have an asp page that contains a user control. This control is a panel containing a number of link buttons that get displayed if certain conditions in the db are met and these conditions can...
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.