473,385 Members | 1,655 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,385 software developers and data experts.

import function from user defined modules

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.

Aug 27 '06 #1
2 2692
groves wrote:
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

Aug 28 '06 #2
groves wrote:
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>

Aug 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Frantisek Fuka | last post by:
This thing keeps bugging me. It's probably some basic misunderstanding on my part but I am stumped. Let's say I have two Python files: file.py and file2.py. Their contents is as follows: ...
2
by: Fritz Bosch | last post by:
Hi experts Is is possible to import/manipulate a module such that I can supply its __dict__? I want to supply my own dict subclass object to be filled by the import, e.g. a class like: >>>...
3
by: Mudcat | last post by:
I have a directory structure that contains different modules that run depending on what the user selects. They are identical in name and structure, but what varies is the content of the functions....
0
by: groves | last post by:
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...
3
by: kwatch | last post by:
What is the condition of module name which is available in 'from .. import ..' statement ? ---------------------------------------- import os print os.path # <module 'posixpath'...
7
by: bambam | last post by:
import works in the main section of the module, but does not work as I hoped when run inside a function. That is, the modules import correctly, but are not visible to the enclosing (global)...
10
by: Thomas Guettler | last post by:
If you look at this code, you see there are two kind of ImportErrors: 1. app_name has no attribute or file managment.py: That's OK. 2. managment.py exists, but raises an ImportError: That's not...
4
by: bvdp | last post by:
Terry Reedy wrote: <snip> <snip> <snip>
13
by: Rafe | last post by:
Hi, I am in a situation where I feel I am being forced to abandon a clean module structure in favor of a large single module. If anyone can save my sanity here I would be forever grateful. My...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.