I have been programming remotely lately by using GitHub codespaces. I have been using the dev container for Python 3 to compile and run my code and it's been working just fine so far.
I currently have a program that is using the Tkinter module. I am pretty sure it has been installed correctly, but I am getting an error message whenever I am running it. I have no idea if it is even possible to run this sort of thing on a GitHub workspace.
The code I have been using is very basic Tkinter code.
Code:
import tkinter
#create main window
master = tkinter.Tk()
master.title("tester")
master.geometry("300x100")
#make a label for the window
label1 = tkinter.Label(master, text="Hello")
# Lay out label
label1.pack()
# Run forever!
master.mainloop()
Whenever I try running this code on a GitHub codespace with my dev container I end up getting this error message:
*Traceback (most recent call last):
File "/workspaces/compile-python/cheese.py", line 4, in <module>
master = tkinter.Tk()
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/tkinter/__init__.py", line 2345, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: no display name and no $DISPLAY environment variable*
I understand that it might not even be possible in general and that it might not be because of the way I wrote the code.