Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

TclError: no display name and no $DISPLAY enviroment variable problem when autostart

Wed Jan 02, 2019 7:01 am

Hello guys. I have a some problem. I made python program and used tkinter for GUI. My program auto start when raspberry pi start. Normally my program work good. But If I use terminal, I take tcl Error. Main problem appear when I use watchdog.py. When my program begin I take this error and rpi reboot itself(Watchdog work). If I don't use watchdog.py, there is no problem, my GUI work fine. I overcome this error for use watchdog.py. My entire of error, below:

Code: Select all

File "/home/pi/Petra/PGUI.py", line 348, in <module>
	root=Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1823, in __init__
	self.tk=_tkinter.create(screenName, baseName, className,interactive, want object, useTk, sync, use)
TclError: no display name and no $DISPLAY environment variable
I try write 'export DISPLAY=0.0' into '/etc/rc.local' this time my rpi stack on login. I want to exceed this error but I could not yet.
How can I fix this problem? Any suggestion. Thanks your time.
Regards.

Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Re: TclError: no display name and no $DISPLAY enviroment variable problem when autostart

Wed Jan 02, 2019 8:22 am

I think found it. I think, python program start before Xwindow. But how can i sure this? /home/pi/.config/lxsession/LXDE-pi/autostart file this:

Code: Select all

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@/usr/bin/python /home/pi/Petra/PGUI.py
@xscreensaver -no-splash
@point-rpi
Is it important this queue or not ? Or If I Use delay function, so GUI create after delay function and Desktop open in this time. Is it true method?

Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Re: TclError: no display name and no $DISPLAY enviroment variable problem when autostart

Wed Jan 02, 2019 8:30 am

Unfortunately delay funciton did not work

Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Re: TclError: no display name and no $DISPLAY enviroment variable problem when autostart

Wed Jan 02, 2019 12:01 pm

I found. Trouble there was in autostart. I use '/etc/rc.local' for extra. I comment out autostart command in '/etc/rc.local' and just use '/home/pi/.config/lxsession/LDE-pi/autostart'. My queue this:

Code: Select all

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@/usr/bin/python /home/pi/sample.py
So python program run after Xwindow. And tcl error does not return.

Return to “Python”