简体   繁体   中英

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). 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). 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".

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. 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). 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. 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. Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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