简体   繁体   中英

Issue with tkinter importing on PyCharm (Python 3.6.6)

I'm trying to use tkinter for the first time in python 3.6.6, using PyCharm. After importing tkinter, I wasn't able to use the Tk() function to create a window, but instead got an inspection stating that "Tk()" is an unresolved reference. When I run my short program, it also gives me name error. Can someone please tell me what the issue could be?

from tkinter import *

root = Tk()
root.mainloop()

Try running the following code:

import tkinter as tk

root = tk.Tk()
root.mainloop()

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