具有多个窗口的 Pygame [英] Pygame with Multiple Windows

查看:125
本文介绍了具有多个窗口的 Pygame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要构建一个具有多个窗口的应用程序.在其中一个窗口中,我需要能够玩一个简单的游戏,而另一个窗口必须显示问题并获得影响游戏的用户的响应.

I need to to build an application that has multiple windows. In one of these windows, I need to be able to play a simple game and another window has to display questions and get response from a user that influences the game.

(1) 我想使用 pygame 来制作游戏.有没有简单的方法让 pygame 在多个窗口中运行?

(1) I was wanting to use pygame in order to make the game. Is there a simple way to have pygame operate with multiple windows?

(2) 如果没有简单的方法解决(1),有没有简单的方法可以使用其他python GUI结构,让我同时运行pygame和另一个窗口?

(2) If there is no easy way to solve (1), is there a simple way to use some other python GUI structure that would allow for me to run pygame and another window simultaneously?

推荐答案

简短的回答是否定的,在同一个进程中创建两个 pygame 窗口是不可能的(截至 2015 年 4 月).如果你想用一个进程运行两个窗口,你应该查看 pygletcocos2d.

The short answer is no, creating two pygame windows in the same process is not possible (as of April 2015). If you want to run two windows with one process, you should look into pyglet or cocos2d.

如果您必须使用 pygame,另一种方法是使用进程间通信.您可以有两个进程,每个进程都有一个窗口.他们将使用套接字相互中继消息.如果您想走这条路,请查看套接字教程此处.

An alternative, if you must use pygame, is to use inter-process communication. You can have two processes, each with a window. They will relay messages to each other using sockets. If you want to go this route, check out the socket tutorial here.

这篇关于具有多个窗口的 Pygame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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