import function from user defined modules

G

groves

Can anybody give me an example of how to import a function of module X
in module y. And please if yu can use classes(Object oriented approach)
would be great.

The problem is that I have created a text on canvas, and now I want
that whenever a user right clicks on it, the option COMMAND should
invoke a function defined in some other module say Y.

thanks a lot to all who will look into problem, any help would be
appreciated.
 
S

Simon Forman

groves said:
Can anybody give me an example of how to import a function of module X
in module y. And please if yu can use classes(Object oriented approach)
would be great.

The problem is that I have created a text on canvas, and now I want
that whenever a user right clicks on it, the option COMMAND should
invoke a function defined in some other module say Y.

thanks a lot to all who will look into problem, any help would be
appreciated.

from X import func

Then you can call func() in your module.

Peace,
~Simon
 
F

Fredrik Lundh

groves said:
Can anybody give me an example of how to import a function of module X
in module y. And please if yu can use classes(Object oriented approach)
would be great.

The problem is that I have created a text on canvas, and now I want
that whenever a user right clicks on it, the option COMMAND should
invoke a function defined in some other module say Y.

import Y

widget = Canvas(..., command=Y.function)

for more on this, see the tutorial:

http://docs.python.org/tut/node8.html

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top