2

I can't get my graphics library to work in my code. I use the ubuntu app. Here is some example code and its output:

The code:

from graphics import *

circ = Circle(50)
circ.set_color(Color.red)
circ.set_position(80,120)
add(circ)

The output:

Traceback (most recent call last):
  File "ewfrew.py", line 1, in <module>
    from graphics import *
  File "/home/adam/.local/lib/python3.8/site-packages/graphics.py", line 185, in <module>
    _root = tk.Tk()
  File "/usr/lib/python3.8/tkinter/__init__.py", line 2261, 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 think it's an issue with the graphics library I installed because it says line 185, but I'm not sure.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
polp7
  • 21
  • 1
  • 1
    Where did you get `graphics` from? It's not part of the standard library, doesn't look like, so what did you install? – Green Cloak Guy Jan 13 '21 at 20:23
  • im pretty sure its the one at this site https://www.pas.rochester.edu/~rsarkis/csc161/python/pip-graphics.html – polp7 Jan 13 '21 at 20:45
  • Does this answer your question? [\_tkinter.TclError: no display name and no $DISPLAY environment variable](https://stackoverflow.com/questions/37604289/tkinter-tclerror-no-display-name-and-no-display-environment-variable) – Tomerikoo Jan 14 '21 at 17:58
  • I've looked at that thread and it didn't work but I found a different solution on this thread https://stackoverflow.com/questions/62718967/ubuntu-tkinter-tclerror-no-display-name-and-no-display-environment-variable and I think that fixed one error but I have another error on this thread https://stackoverflow.com/questions/65725071/python-isnt-recognizing-basic-graphics-functions – polp7 Jan 14 '21 at 18:42

0 Answers0