help with tkinter

Peter J. Holzer hjp-python at hjp.at
Fri Aug 9 06:52:37 EDT 2019


On 2019-08-09 10:34:34 +0300, Ahmad Adam Kabbara wrote:
> so when I write from
> tkinter import*
> t=Tk()
> tkinter.colorchooser.askcolor()
> I get this error message
> Traceback (most recent call last):
>   File "C:\Users\kabba\Desktop\color and coordinates.py", line 3, in
> <module>
>     tkinter.colorchooser.askcolor()
> NameError: name 'tkinter' is not defined

You didn't import 'tkinter', you imported all symbols ('*') from
tkinter. So, since you imported colorchooser, you can call 
colorchooser.askcolor() (not tkinter.colorchooser.askcolor())

> the only time it worked is when I typed
> from tkinter import colorchooser
> colorchooser.askcolor()

Here you imported 'colorchooser' from tkinter. So you can call
colorchooser.askcolor(). Same as above, except that you have only
imported colorchooser and not the myriad of other symbols that '*' would
import.

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20190809/89733833/attachment.sig>


More information about the Python-list mailing list