import function from user defined modules

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • groves

    #1

    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.

  • Simon Forman

    #2
    Re: import function from user defined modules

    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

    Comment

    • Fredrik Lundh

      #3
      Re: import function from user defined modules

      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.funct ion)

      for more on this, see the tutorial:



      </F>

      Comment

      Working...