Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pygame dual monitors and fullscreen

Tags:

python

pygame

I am using pygame to program a simple behavioral test. I'm running it on my macbook pro and have almost all the functionality working. However, during testing I'll have a second, external monitor that the subject sees and the laptop monitor. I'd like to have the game so up fullscreen on the external monitor and not on the laptop's monitor so that I can monitor performance. Currently, the start of the file looks something like:

#! /usr/bin/env python2.6

import pygame
import sys

stdscr = curses.initscr()
pygame.init()
screen = pygame.display.set_mode((1900, 1100), pygame.RESIZABLE)

I was thinking of starting the game in a resizable screen, but that OS X has problems resizing the window.

like image 450
MudPhud Avatar asked Aug 17 '11 17:08

MudPhud


People also ask

How do I make pygame full screen?

If we run the example above, we will see a little window, sized by the width and height variables. If we want a game to be fullscreen, we pass the pygame. FULLSCREEN flag, and there you have it, a fullscreen Pygame window.

What does pygame display flip do?

display. flip() for software displays. It allows only a portion of the screen to updated, instead of the entire area. If no argument is passed it updates the entire Surface area like pygame.

What is pygame display Set_mode?

pygame.display.set_mode. — initialize a window or screen for display.


1 Answers

Pygame doesn't support two displays in a single pygame process(yet). See the question here and developer answer immediately after, where he says

Once SDL 1.3 is finished then pygame will get support for using multiple windows in the same process.

So, your options are:

  1. Use multiple processes. Two pygame instances, each maximized on its own screen, communicating back and forth (you could use any of: the very cool python multiprocessing module, local TCP, pipes, writing/reading files, etc)
  2. Set the same resolution on both of your displays, and create a large (wide) window that spans them with your information on one half and the user display on the other. Then manually place the window so that the user side is on their screen and yours is on the laptop screen. It's hacky, but might a better use of your time than engineering a better solution ("If it's studpid and it works, it ain't stupid" ;).
  3. Use pyglet, which is similar to pygame and supports full screen windows: pyglet.window.Window(fullscreen=True, screens[1])

Good luck.

like image 52
coffeetocode Avatar answered Sep 21 '22 18:09

coffeetocode