pygame 双显示器和全屏 [英] pygame dual monitors and fullscreen

查看:114
本文介绍了pygame 双显示器和全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 pygame 编写一个简单的行为测试.我在我的 macbook pro 上运行它,几乎所有功能都在运行.但是,在测试期间,我将有第二台外部显示器和笔记本电脑显示器供受试者看到.我想让游戏在外接显示器上全屏显示,而不是在笔记本电脑的显示器上,这样我就可以监控性能.目前,文件的开头看起来像:

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)

我想在可调整大小的屏幕中启动游戏,但 OS X 在调整窗口大小时遇到​​问题.

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

推荐答案

Pygame 不支持单个 pygame 进程中的两个显示器(目前).请参阅问题此处和开发人员回答紧接着,他说

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

SDL 1.3 完成后,pygame 将支持在同一进程中使用多个窗口.

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

所以,您的选择是:

  1. 使用多个进程.两个 pygame 实例,每个实例都在自己的屏幕上最大化,来回通信(您可以使用以下任何一个:非常酷的 python 多处理模块、本地 TCP、管道、写入/读取文件等)
  2. 在您的两个显示器上设置相同的分辨率,并创建一个大(宽)窗口,将您的信息显示在它们的一半上,而用户显示在另一边.然后手动放置窗口,让用户端在他们的屏幕上,而你的在笔记本电脑屏幕上.这很hacky,但可能比设计更好的解决方案更好地利用您的时间(如果它很笨拙并且有效,它就不是愚蠢的";).
  3. 使用 pyglet,它类似于 pygame 并且支持全屏窗口:<代码>pyglet.window.Window(fullscreen=True,screens[1])
  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])

祝你好运.

这篇关于pygame 双显示器和全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆