i got this error message whenever I tried to call zenity in a cron job of a user. I found some hints in the net but still failed. But's its just 2 commands you have to add.
Add in .bashrc
[[ $DISPLAY ]] && xhost +localhost
Now add following line in the code calling Zenity
echo "# Backing up user data ..."
sudo rsnapshot daily
) | DISPLAY=':0.0' zenity --title="Backup running - do not close lid or shut down system" --progress --pulsate --auto-close --width=800 &