简体   繁体   English

Python 3.8.9 MacOS M1 tkinter UI 未在 VSCode 内部打开

[英]Python 3.8.9 MacOS M1 tkinter UI not opening inside of VSCode

so I am trying to use Tkinter inside of VSCode on my M1 mac.所以我试图在我的 M1 mac 上的 VSCode 中使用 Tkinter。 When I use Tkinter through IDLE it works fine but once I try to open it inside of VSCode it the UI submenu just stalls.当我通过 IDLE 使用 Tkinter 时它工作正常但是一旦我尝试在 VSCode 中打开它它 UI 子菜单就会停止。 I'm using python 3.8.9 as my kernel but it won't seem to open even when I switch to any other versions.我正在使用 python 3.8.9 作为我的 kernel,但即使我切换到任何其他版本,它似乎也无法打开。 Tkinter is installed fine it is just some issue with how VSCode is running it but I have no idea how to fix it. Tkinter 安装正常,这只是 VSCode 运行方式的一些问题,但我不知道如何修复它。

    import tkinter as tk
    window = tk.Tk()

Here I provided some screenshots of what happens在这里,我提供了一些发生的截图

While using Idle使用空闲时

While using VSCode (The app just bounces up and down never opening the UI)使用 VSCode 时(该应用程序只是上下弹跳而不会打开 UI)

You have not started the event loop.您尚未启动事件循环。 IDLE does mainloop for you, otherwise, you need to call it by yourself. IDLE 为你做 mainloop,否则,你需要自己调用它。

import tkinter as tk
root = tk.Tk()
root.mainloop()

You can refer to here .你可以参考这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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