Forums

tkinter dont work

Hi, i got this code

#calculator
from tkinter import *
vnt= Tk()
vnt.geometry("500x500")
vnt.title("Calculator")
lblSaludo = Label(vnt, text="Hello world");
lblSaludo.place(x=20,y=20)
btnSalir = Button(vnt, text="Salir", command=vnt.quit)
vnt.mainloop()

I execute with command python3.7 ventanaUno.py and this is the error:

Traceback (most recent call last): File "ventanaUno.py", line 7, in <module> vnt= Tk() File "/usr/lib/python3.7/tkinter/init.py", line 2020, in init self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable

Someone can explain to me wath is happened

Thks

There is no screen for tkinter to draw on. That is essentially what the error is saying.

hi glenn,,, that mean Tkinter cant support by pythonanywhere,,,, I need to change the library?

For example, where would the button be displayed? This wouldn't work for any cloud service.

[Unhelpful comment deleted by admin]