【发布时间】:2021-10-12 02:39:26
【问题描述】:
我安装了 PySimpleGUI 并将“Jump-Start”代码复制/粘贴到 vs 代码中。我尝试运行它,它不断吐出错误
Exception has occurred: ModuleNotFoundError (note: full exception trace is shown but execution is paused at: <module>)
No module named '_tkinter'
File "/home/x/Code/PySimGui/testing_it_out.py", line 1, in <module> (Current frame)
import PySimpleGUI as sg
我已经安装了 tkinter 使用
sudo apt-get install python-tk python3-tk tk-dev
...帮助
编辑: 这是我的代码:
import PySimpleGUI as sg
sg.theme('DarkAmber') # Add a touch of color
# All the stuff inside your window.
layout = [ [sg.Text('Some text on Row 1')],
[sg.Text('Enter something on Row 2'), sg.InputText()],
[sg.Button('Ok'), sg.Button('Cancel')] ]
# Create the Window
window = sg.Window('Window Title', layout)
# Event Loop to process "events" and get the "values" of the inputs
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel
break
print('You entered ', values[0])
window.close()
【问题讨论】:
-
欢迎您!你能分享你正在尝试的确切代码吗?
-
通过执行命令
dpkg -L python3-tk查看python3-tk包支持的Python版本。 -
它列出了 python 3.8 和 3.9 作为支持的版本
-
那么 VS 代码中使用的 Python 是支持的版本之一吗?
-
是的,它是 python 3.9
标签: python python-3.x tkinter pysimplegui