export DISPLAY=:0.0
If it still fails after that, then there's some security or something getting in the way. To prove this, you can do this from either root or the original user:
xhost +
and then try to open the window. But this is horribly insecure for many people. Maybe Bitt can help more here now.
Correction.. it seems that
xhost + works
only when issued by the original user (owner of the X session). Oddly, the man page suggests we could be safer with
xhost +root@, but it doesn't work for me here.
Cheers