简体   繁体   中英

Python turtle: problems with tkinter

So I wanted to use the python package turtle, which uses the underlying package tkinter. With this code:

import turtle

python raised an error which said, that the package tkinter was not found. So I edited the turtle.py file and changed the

from tkinter import xyz

to

from tk import xyz

and at least the error was gone, but another appeared. It is now saying

ImportError: cannot import name 'simpledialog' from 'tk' (C:\PYTHON\lib\site-packages\tk\__init__.py)

I've updated pip and reinstalled both packages. I'm using python 3.9.1 on Windows.

Try using:

from tkinter.simpledialog import askstring

Or whichever type of simpledialog you want to make

Feel free to ask question in case of confusion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM