Hi,
Is it possible to use Raspberry Pi 4 and Pygame 2 with either two (HDMI, HDMI) or three (DSI, HDMI, HDMI) monitors?
Thanks!
- peppy.player
- Posts: 461
- Joined: Mon Mar 07, 2016 6:10 am
Re: Pygame 2 & Multiple Monitors
I’ve done this a while ago with 2 screens. Just treat them as 1 huge graphics area.
- peppy.player
- Posts: 461
- Joined: Mon Mar 07, 2016 6:10 am
Re: Pygame 2 & Multiple Monitors
OK, so you draw on one part of the screen which will be shown on display 1 and another part will be shown on display 2. Just wondering if this approach will be possible using Pygame and Raspberry Pi 5 which has two DSI ports. The idea is to display the main audio player interface on HDMI display and use two other displays (e.g. DSI) to show left and right VU Meter channels.
Re: Pygame 2 & Multiple Monitors
Hmm, either I was mistaken or it may have been a quirk of a previous OS or pygame.
pygame2 still only has one display surface per process I believe:
The following code draws a line on screen 0 then closes that screen returning to the desktop, then draws a line on screen 1 then closes that screen returning to the desktop . Not very helpful!
python 3.9.2 pygame 2.5.1
pygame2 still only has one display surface per process I believe:
https://www.pygame.org/docs/ref/display.htmlPygame has a single display Surface that is either contained in a window or runs full screen.
The following code draws a line on screen 0 then closes that screen returning to the desktop, then draws a line on screen 1 then closes that screen returning to the desktop . Not very helpful!
python 3.9.2 pygame 2.5.1
Code: Select all
import pygame,os,time,sys
print('begin')
print('python:',sys.version)
print('pygame:',pygame.version.vernum )
pygame.init()
lcd1 = pygame.display.set_mode((0, 0), pygame.FULLSCREEN,display=0)
lcd1.fill(pygame.Color('black'))
pygame.draw.line(lcd1,pygame.Color('red'),(0,0),(1920,1080),1)
pygame.display.update()
time.sleep(2)
lcd2 = pygame.display.set_mode((0, 0), pygame.FULLSCREEN,display=1)
lcd2.fill(pygame.Color('black'))
pygame.draw.line(lcd2,pygame.Color('blue'),(0,0),(1920,1080),1)
pygame.display.update()
time.sleep(2)
pygame.quit()
print('end')
Re: Pygame 2 & Multiple Monitors
The following using multiprocessing works but is hacky and you would have to communicate between processes.
Code: Select all
from multiprocessing import Process
import time
import pygame,os,time,sys
def a():
pygame.init()
lcd1 = pygame.display.set_mode((0, 0), pygame.FULLSCREEN,display=0)
lcd1.fill(pygame.Color('black'))
pygame.draw.line(lcd1,pygame.Color('red'),(0,0),(1920,1080),1)
pygame.display.update()
time.sleep(4)
pygame.quit()
def b():
pygame.init()
lcd2 = pygame.display.set_mode((0, 0), pygame.FULLSCREEN,display=1)
lcd2.fill(pygame.Color('black'))
pygame.draw.line(lcd2,pygame.Color('blue'),(0,0),(1920,1080),1)
pygame.display.update()
time.sleep(4)
pygame.quit()
if __name__ == '__main__':
pa = Process(target=a)
pa.start()
pb = Process(target=b)
pb.start()
pa.join()
pb.join()
print('end')
- peppy.player
- Posts: 461
- Joined: Mon Mar 07, 2016 6:10 am
Re: Pygame 2 & Multiple Monitors
Thank you! That looks promising. Can I use Threads instead of Processes?
Another question is how those DSI outputs of Pi 5 can be handled in Pygame? The same way as HDMI? Probably nobody knows the answer until we put our hands on Pi 5
Another question is how those DSI outputs of Pi 5 can be handled in Pygame? The same way as HDMI? Probably nobody knows the answer until we put our hands on Pi 5

Re: Pygame 2 & Multiple Monitors
Don't think Threads will work, still the same process I guess. I'll try if I get time.
My Pi5 is pre-ordered
My Pi5 is pre-ordered
