1

I'm new to programing and I'm writing my first python program using quickly. I have added new window and on this new window I want to call function from main window? I google for it and all I found is that I nned to import it but it didnt know how.

Here is what I put new window:

from magic_ebay.MagicEbayWindow import MagicEbayWindow

and I get error:

ImportError: cannot import name MagicEbayWindow

MagicEbayWindow.py is the name of main window in my program and I want to call function from MagicEbayWindow.py but on other window. ( dont know if it make any sense :) )

Thanks for any help!

4
  • Needs some context. You could parse parent structures to walk up from a child, pass in a pointer to the class instance (once it's abstracted it's actually a pointer to an instance), or make it a global. Do you have this in a ppa/github or something? Jul 19, 2012 at 20:48
  • no do don't have it on github.
    – Majster-pl
    Jul 19, 2012 at 20:53
  • then you want to be looking at adding to sys.path, but there's not much more i can say without context Jul 19, 2012 at 21:18
  • thanks for your help, I will try to drop it to github tonight... thanks
    – Majster-pl
    Jul 19, 2012 at 21:42

1 Answer 1

1

When you run:

from magic_ebay.MagicEbayWindow import MagicEbayWindow

You are essentially saying "Please import the MagicEbayWindow symbol from the MagicEbayWindow module in the magic_ebay package". The error message indicates that your MagicEbayWindow.py module doesn't have such a symbol.

There are a few ways you could fix this:

  1. Just import the module:

    from magic_ebay import MagicEbayWindow
    

    You can then access functions within the module as e.g. MagicEbayWindow.foo()

  2. Import individual functions from the module:

    from magic_ebay.MagicEbayWindow import foo
    

    With this style, you can call the functions without the module name prefix.

2
  • Ok I got it finally :) instead:
    – Majster-pl
    Jul 20, 2012 at 20:54
  • Ok I got it finally :) instead: from magic_ebay import MagicEbayWindow i did: import MagicEbayWindow and it work! now when i want to call function from MagicEbayWindow i need to do : mee = MagicEbayWindow.MagicEbayWindow() mee.foo(self) I might doing it all way around but it work for me for now! THANK YOU!
    – Majster-pl
    Jul 20, 2012 at 21:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .