Linked Question: Mac OS X: _tkinter.TclError: no display name and no $DISPLAY environment variable
The above has the same issue but the answer to that doesn't apply to me.
a.py
from Tkinter import *
root = Tk()
canvas = Canvas(bg='white', width = 200, height = 200)
canvas.pack()
canvas.create_line(0, 0, 199, 199, fill="blue", width = 5)
canvas.create_line(0, 199, 199, 0, fill="blue", width = 5)
canvas.update()
canvas.postscript(file = "x.ps")
root.mainloop()
a.py is on a remote server
This works fine when I connect to a server via VNC and run it.
But when I connect to a server via Putty on windows and run it, it gives me "no display name and no diplay environment variable"
1) Is it possible to run this through Putty?
2) Can python know if a connection is made through putty and maybe raise my own error instead of TclError?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…