Tkinter配置

问题描述 投票:0回答:3

我是编程新手,并且正在使用pycharm作为我的IDE。

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

不确定我为什么收到此错误,我也安装了Tk库,仍然收到错误。我正在使用Mac。

python tkinter pycharm tkinter-layout
3个回答
0
投票

[如果您使用的是python3,请使用

import tkinter

0
投票

好,如果您使用的是python 3.8,则在安装安装程序中,它具有以下选择:

enter image description here


如果这不能解决您的问题,请阅读python官方文档:IDLE and tkinter with Tcl/Tk on macOS


-2
投票

要使用世界创建窗口,请使用此

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
© www.soinside.com 2019 - 2024. All rights reserved.