2
votes

I'm trying to draw something pretty simple using pygame. I have a file draw.py, which I'm running by simply typing python draw.py That's how I'm initializing the screen in the code.

import pygame
screen = pygame.display.set_mode((width, height))

Weirdly, instead of starting an external window, things get drawn in the terminal, making the drawing some kind of ASCII art. I tried doing different things, such as running pygame.init() or pygame.display.init() after importing pygame but there is something I don't understand about pygame.

I would like pygame to open a separate graphical window and draw things there. How can I achieve that?

(If that makes any difference, I'm sshing (with -X) to the machine on which I'm working).

1
Ah yes, that almost certainly does make a difference. Have you set up the machine to enable X11 forwarding? - Ari Cooper-Davis
Could you post a screenshot? I'm curious about how it looks. - skrx
@Ari Cooper-Davis. You were right. I was because of the settings of X11. - Deeplearningmaniac
@skrx That's what it looks like. ibb.co/i8qqO5 - Deeplearningmaniac

1 Answers

0
votes

You have to set up the machine to enable X11 forwarding:

X11 forwarding needs to be enabled on both the client side and the server side.

On the client side, the -X (capital X) option to ssh enables X11 forwarding, and you can make this the default (for all connections or for a specific connection) with ForwardX11 yes in ~/.ssh/config.

On the server side, X11Forwarding yes must be specified in /etc/ssh/sshd_config. Note that the default is no forwarding (some distributions turn it on in their default /etc/ssh/sshd_config), and that the user cannot override this setting.