BBB, Debian, Chipsee display: Tkinter gives error

Hello Learned Group,

I have a BBB running Debian (2015-11-03 version) with a Chipsee 4.3 display. It works great, so far so good: both in graphic mode and text. I try to script an application requiring a GUI, so I loaded Tkinter and entered a test program.
This is the result:

Traceback (most recent call last):
File “testtk.py”, line 2, in
root = Tkinter.Tk()
File “/usr/lib/python2.7/lib-tk/Tkinter.py”, line 1712, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
root@beaglebone:/home/apptest#

Its the same whether I run from BBB via bash or via another pc with Cloud9.

I googled a lot and the error is not uncommon, but could not find a clue for my case.

Please advise, regards,
Harke

Harke:
Another in the Learned Group, I think it was Steve Plant but I can’t find the post, suggested connecting a keyboard and mouse to the BBB and running the Python program with ‘sudo python your_python_program’. That worked great for me. I never would have thought of it. My code is a GUI with buttons, text boxes and an animation graph running Tkinter and also running PyBBIO for PWM output and ADC inputs.
John
johnbakeree.blogspot.com

It looks like you need to set the DISPLAY environment variable so that tkinter knows which display to use.

Is X11 installed on the BBB?

On my linux machine, when I try echo $DISPLAY, I get “:0.0” without the quotes.

What happens if you run that command?

You might check out some of the info on this page as well.

http://unix.stackexchange.com/questions/17255/is-there-a-command-to-list-all-open-displays-on-a-machine

–David

Hello David and John,

Thanks for your reactions. Sorry for the delay, was occupied with some other duties like skiing…
echo $DISPLAY from the debian command line returns nothing (a blank line).
The same command form the debian command line coming from the LXDE interface gives: :0. So I issue the sudo python myprog.py command after the LXDE shell has been loaded: that works for me.I need sudo because of the Adafruit library, but I suppose that is another story.
Would be great to run the program without LXDE but I guess that will not work.
The next problem is: how to run the program automatically upon start-up. I prefer without LXDE but I am afraid that is not possible. So I need to start myprog.py form a kind of start-up script…
Btw: what is X11? The link is not terribly clear for me as a novice…

Best regards,
Harke

Hi Harke,

X11 is the X window system rev 11. It’s the most basic graphics layer on a desktop system. By itself, it just allows you to create graphical windows, but doesn’t manage them in any way. That’s where LXDE comes in. LXDE sits on top of X11 and provides useful “desktop user” type features like window management, a clipboard for copy and paste between applications, a program menu launcher, etc…

About starting your program, you really shouldn’t need to have LXDE. You should be able to to add your “python my_program.py” to a .xinitrc file and get what you are looking for. This uses X11 at its most basic level, without providing “start menu” etc.

https://wiki.debian.org/Xinitrc
http://blog.falconindy.com/articles/back-to-basics-with-x-and-systemd.html
https://wiki.gentoo.org/wiki/X_without_Display_Manager

After poking around a bit, I found that you might like a package called nodm.
https://github.com/spanezz/nodm
https://packages.debian.org/jessie/nodm
http://jeffhoogland.blogspot.com/2011/12/howto-get-right-to-x-with-no-display.html

I’ve not used it, but now that I’ve seen this, I will give it a try myself!

I hope this helps!

–David