Tkinter configuration

Deadly 提交于 2020-06-01 04:48:25

问题


I'm super new to programming and I'm using pycharm as my IDE.

import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'

Not sure why I get this error, I installed the Tk library as well and still get the error. I am using a Mac.


回答1:


If you are using python3 please use

import tkinter



回答2:


Well,if you are using python 3.8,In the install Setup,it has this choice:


If this couldn't solve your problem,Read the python official document:IDLE and tkinter with Tcl/Tk on macOS.




回答3:


To create a window with hello world use this

from tkinter import *
from tkinter.ttk import *          # importing themed widget library

root = Tk() # creating the root master application object
label = Label(root, text="Hello World") # simple text: hello world
label.pack()                           #Places label into its parent
root.mainloop()                           # running the mainloop


来源:https://stackoverflow.com/questions/61347719/tkinter-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!