import function from user defined modules

Discussion in 'Python' started by groves, Aug 27, 2006.

  1. groves

    groves Guest

    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.
    groves, Aug 27, 2006
    #1
    1. Advertising

  2. groves

    Simon Forman Guest

    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
    Simon Forman, Aug 28, 2006
    #2
    1. Advertising

  3. 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>
    Fredrik Lundh, Aug 28, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Remy Cool
    Replies:
    1
    Views:
    419
    Remy Cool
    Aug 27, 2003
  2. groves
    Replies:
    0
    Views:
    229
    groves
    Aug 27, 2006
  3. Oodini
    Replies:
    1
    Views:
    1,749
    Keith Thompson
    Sep 27, 2005
  4. Replies:
    1
    Views:
    481
    Sion Arrowsmith
    Jul 10, 2008
  5. Alok
    Replies:
    3
    Views:
    237
Loading...

Share This Page