Skip to content Skip to sidebar Skip to footer

Tkinter Error: No Display Name And No $display Environment Variable

I'm working on TkInter on Repl.it and have run into a problem, this is my code: from tkinter import * import tkinter as tk root = tk.Tk() root.geometry('400x400') I run into

Solution 1:

You're apparently trying to do this with repl.it's "Python", which doesn't support the display that tkinter needs. They do offer a separate "Tkinter" option, although it's quite far down the list of languages. Here's a shortcut: https://repl.it/languages/tkinter

There you don't get that error. In order to actually get the window shown, you'll have to also add this under your current code:

root.mainloop()

Demo

Solution 2:

from tkinter import *  
  
top = Tk()  
  
top.geometry("400x250")  
  
#creating label  
uname = Label(top, text = "Username").place(x = 30,y = 50)  
  
#creating label  
password = Label(top, text = "Password").place(x = 30, y = 90)  
  
  
sbmitbtn = Button(top, text = "Submit",activebackground = "pink", activeforeground = "blue").place(x = 30, y = 120)  
  
e1 = Entry(top,width = 20).place(x = 100, y = 50)  
  
  
e2 = Entry(top, width = 20).place(x = 100, y = 90)  
  
  
top.mainloop()  

Post a Comment for "Tkinter Error: No Display Name And No $display Environment Variable"