[英]How do I execute a window above a website, with a Python console?
I am learning Python right now and I wanted to ask if there is a way to open a window above a website where you are able to run a console (I'm using repl.it). 我现在正在学习Python,我想问一下是否有一种方法可以在网站上方打开一个您可以运行控制台的窗口(我使用的是repl.it)。 I can't use a normal installed version of Python, because I am not able to install it on the school computers (They are running a server system and I don't have any privileges on those).
我无法使用Python的常规安装版本,因为我无法在学校计算机上安装Python(它们正在运行服务器系统,而我在这些计算机上没有任何特权)。 So, am I even able to do it, or do I have to do it in another way like im thinking of?
因此,我什至能够做到这一点,还是我必须以其他方式来做到这一点? Until now I just wrote a realy simple code for executing a window with "tkinter".
到目前为止,我只是编写了一个非常简单的代码来使用“ tkinter”执行窗口。
import tkinter
window = tkinter.Tk()
window.mainloop()
The resutlt I allways get is: 我一直得到的结果是:
Traceback (most recent call last):
File "python", line 3, in <module>
_tkinter.TclError: no display name and no $DISPLAY environment variable
You wont be able to open up a window on your computer since essentially everything that you try to do is not really happening on your computer. 您将无法在计算机上打开一个窗口,因为实际上您尝试执行的所有操作实际上都不在计算机上发生。 You are sending text to a server, it processes it there, then it replies with what python told it.
您正在将文本发送到服务器,然后在服务器上对其进行处理,然后使用python的回答进行回复。 At best you would be able to open the window on the server then essentially get a live display of what is happening that you could interact with in the same way that you send text input, however the server you are running will not be able to do this (it likely doesn't have the ability to display anything, and certainly they wont let you view any display / ssh in).
充其量,您将能够打开服务器上的窗口,然后从本质上实时显示可以与发送文本输入相同的方式进行交互的内容,但是正在运行的服务器将无法执行此操作这(它可能无法显示任何内容,并且当然它们不会让您查看任何显示/ ssh)。 If you want to, you could try hosting your own server that has a display, then using X11 forwarding through an ssh connection you could open it on your computer.
如果愿意,您可以尝试托管自己的具有显示器的服务器,然后使用通过ssh连接进行X11转发来在计算机上打开它。 However, knowing school computers, this is probably blocked as well.
但是,了解学校计算机后,这也可能被阻止。 It's also possible you could install a portable version of python on a usb disk and run tkinter from that, which would be a lot easier, again assuming that the school computers allow that.
也有可能您可以在USB磁盘上安装可移植版本的python并从中运行tkinter,这将容易得多,再次假设学校计算机允许这样做。 Good luck!
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.