Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > scope acting weird

Reply
Thread Tools

scope acting weird

 
 
Gabriel B.
Guest
Posts: n/a
 
      05-01-2005
i have the following code:

Ui.py:
import Tkinter as Tk
import UiMainScreen

UiMainScreen.py:
class UiMainScreen( Tk.Frame ):
....

and i get the following error:
File "UiMainScreen.py", line 1, in ?
class UiMainScreen(Tk.Frame):
NameError: name 'Tk' is not defined

isn't Tk supposed to be imported globaly?
And If i import Tkinter again inside every other file, will it be
really imported several times and be independent in each file or the
python interpreter just use the subsequent imports to know where to
propagate stuff?

Thanks,
Gabriel
 
Reply With Quote
 
 
 
 
Mike Meyer
Guest
Posts: n/a
 
      05-01-2005
"Gabriel B." <> writes:

> i have the following code:
>
> Ui.py:
> import Tkinter as Tk
> import UiMainScreen
>
> UiMainScreen.py:
> class UiMainScreen( Tk.Frame ):
> ....
>
> and i get the following error:
> File "UiMainScreen.py", line 1, in ?
> class UiMainScreen(Tk.Frame):
> NameError: name 'Tk' is not defined
>
> isn't Tk supposed to be imported globaly?


No. import only affects thye module it's in. You need to add "import
Tk" to UiMainScreen.py.

> And If i import Tkinter again inside every other file, will it be
> really imported several times and be independent in each file or the
> python interpreter just use the subsequent imports to know where to
> propagate stuff?


The module is only imported once. The second and further imports link
the name Tk in the importing module to the Tk module already imported.

<mike
--
Mike Meyer <> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET acting weird in Windows 2003 server David ASP .Net 5 04-21-2005 04:22 PM
Firefox acting weird maradcliff@UNLISTED.com Firefox 4 11-15-2004 03:16 AM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-20-2004 12:07 PM
Hard drive really acting weird Will Smith Computer Support 13 12-18-2003 03:33 AM
NS7.1 -- busted Moz registry? JMC acting weird... Gordon S. Hlavenka Firefox 1 10-31-2003 02:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57