GTK Ubuntu 17.10 [duplicate]

By default 17.10 does not allow root to access your display.

Try the command xhost +si:localuser:root then launch gedit with root privilege.