简体   繁体   English

如何使用Python控制台执行网站上方的窗口?

[英]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.

相关问题 我想在我的tkinter窗口中嵌入python控制台..我怎么能这样做? - I want to embed python console in my tkinter window.. How can i do it? PYTHON 如何打开新控制台并在 python 中的 window 上打印字符串 - PYTHON How to open new console and do print strings on that window in python python程序终止后,如何保持控制台窗口打开以查看产生的任何错误? - How do I keep a console window open after my python program terminates to see any errors produced? 如何使用 python 制作一个 800x800 的控制台窗口 - How do I make a 800x800 console window with python 如何在按下按钮后执行命令,同时在python中也使用按钮关闭窗口(使用tkinter)? - How do I execute a command after pushing a button while also closing the window with the button in python (with tkinter)? 我如何在python中获得高于和低于平均水平? - How do I get the above and below the average in python? 如何在Python控制台中重新加载模块? - How do I reload a module in the Python console? 如何在函数中关闭 tkinter 窗口后执行命令? - How do I execute commands after a tkinter window closes in a function? 如何使用python 3下载网站? - How do I download a website using python 3? 如何在 python 中将平方根打印到控制台? - How do I print a square root to the console in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM