yeah, i run in ssh : pi@raspberrypi ~ $ sudo python tk.py... it successful run and prompt out a Xming server in window but not in raspi..weird. any clue? =(KenT wrote:Weird. i would expect the opposite
I think Tkinter will not work from SSH but should work from LXTerminal on the Pi
By compile i assume you mean run as in python myprog.py
Code: Select all
echo $DISPLAY
:0.0Code: Select all
export DISPLAY=:0.0Code: Select all
xhost +
access control disabled, clients can connect from any hostOMG. It solve the problem. Thanks alot!!! =)DBryant wrote:You've not given too many details on the way you are invoking your Python app.
Via ssh you are, by some means, enabling X11 forwarding (ssh -X ...) in which graphic traffic comes back to the X server on the system you invoked the ssh command. The mechanics of ssh ensures that the correct DISPLAY is forwarded to the remote app, so it knows where to send its output. It usually manages to sort out authentication, although you may see some warning messages; we generally ignore them because the application runs!
On an LXterminal then the (default) X server is the created during the startx process; same app but a completely different graphical display. And the authentication is not complete in this basic environment, but apparently it is in IDLE. In the LXterminal then runwhich reports the graphical display that will be used by default. In this case display 0, screen 0 on the localhost. If is does't report anything thenCode: Select all
echo $DISPLAY :0.0where were guessing there's only a single display with the usual numbers.Code: Select all
export DISPLAY=:0.0
Then extend the authentication withthis open up access to the local X server as reported by the command. Now try to run your Python application in the LXterminal.Code: Select all
xhost + access control disabled, clients can connect from any host
If it works the appropriate commands can be inserted in the shell startup file (for bash this is .bashrc). You might want to read man xhost http://unixhelp.ed.ac.uk/CGI/man-cgi?xhost+1 and man xauth http://www.x.org/archive/X11R6.8.1/doc/xauth.1.html since there are security issues with opening up access for X11 traffic. Not a serious issue on a home network behind a router/firewall, but something to be aware of.
Hope this helps