repl.it 上的 Tkinter 模块“没有显示名称或 $DISPLAY [英] Tkinter module on repl.it "no display name or $DISPLAY

查看:27
本文介绍了repl.it 上的 Tkinter 模块“没有显示名称或 $DISPLAY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在 Repl.it 上的 Python 3 上运行的代码,不幸的是,当我尝试使用 Tkinter 模块创建窗口时,它似乎找不到显示环境.为什么会这样,是否有解决方法?

this is my code which I am running on a Python 3 on Repl.it, unfortunately when I try and use the Tkinter module to create a window, it can't seem to find a display environment. Why is this and is there a fix for it?

    import tkinter
    window = tinter.Tk()

错误是_tkinter.TclError: no display name and no $DISPLAY environment variable"预先感谢您的帮助

And the error is "_tkinter.TclError: no display name and no $DISPLAY environment variable" Thanks in advance for your help

推荐答案

不幸的是,我不相信您可以在 repl.it 上配置它,如果可以,我认为这不值得麻烦.尝试在本地运行您的程序.

Unfortunately, I don't believe you can configure this on repl.it, and if you could, I don't think it would be worth the hassle. Try running your program locally.

让我试着用一个例子来回答这个问题.

Let me try and answer this with an example.

$DISPLAY 环境变量用于指向您在 PC 上运行的任何 X 服务器应用程序.tkinter 将查看您的 $DISPLAY 变量以启动 X 服务器应用程序(它将启动用于图形界面的 X11 协议).

The $DISPLAY environment variable is used to point to any X-server applications you have running on your PC. tkinter will look to your $DISPLAY variable to launch the X-server application (which in turn will launch the X11 protocol used for graphical interfaces).

这篇关于repl.it 上的 Tkinter 模块“没有显示名称或 $DISPLAY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆