[Tutor] Why can't I import this?

Dick Moores rdm at rcblue.com
Wed Nov 29 04:32:54 CET 2006

At 07:20 PM 11/28/2006, Kent Johnson wrote:
>Dick Moores wrote:
> > I just discovered something for Tkinter that I want to use. It's a
> > Tooltip class, at <http://tkinter.unpythonic.net/wiki/ToolTip> .
> >
> > I've copied it to a file I named toolTipDemo.py and put it with a
> > couple of other files I use as modules. They're in
> > E:\Python25\Lib\site-packages\mine. One file there is intSpell.py,
> > and I can import it by
> >
> > from mine.intSpell import intSpell
> >
> > With no problem:
> >  >>> from mine.intSpell import intSpell
> >  >>>
> > However, the same method of importing doesn't work with toolTipDemo:
> >  >>> from mine.toolTipDemo import toolTipDemo
> > Traceback (most recent call last):
> >    File "<string>", line 1, in <string>
> > ImportError: cannot import name toolTipDemo
>from mine.toolTipDemo import demo
>mine.toolTipDemo points to the module, then you need to reference a name
>defined in the module. (You must have something called intSpell in

Interestingly (or not) it just hit me that I should try that, and it 
worked. So I suppose that if I want to use tooltips in a Tkinter 
program, I can just use  "from mine.toolTipDemo import *" and use 
what I need. (Haven't tried that yet, however.)

Thanks, Kent.


More information about the Tutor mailing list