我正在编写一个简单的图像查看器,并且已经到了我想要在显示之间切换的地步。
我有一个渲染图像的方法,里面有:
def on_key_press(symbol, modifiers):
if symbol == key.S:
if not self.msgbox_active:
self.msgbox_active = True
ret = int(choicebox(
msg='Choose screen to switch to',
title='Screen selection',
choices=[*range(1, len(self.screens) + 1)],
))
if ret and ret - 1 != self.show_on :
self.show_on = ret - 1
self.window.set_fullscreen(True, screen=self.screens[self.show_on])
else:
self.msgbox_active = False
self.action = 'self'
我想重绘一个窗口,但由于事实上我需要提前初始化
pyglet.window.Window
。当我 window.close()
然后初始化它时,它会抱怨 pyglet.gl.ContextException: Unable to share contexts.
我猜这是因为已经有一个窗口了(尽管 pyglet 上下文文档 states each window has it's own context
。
有没有办法更新 Window
的屏幕属性而不(或)重新创建它?
要将窗口移动到另一个屏幕,我们需要:
self.window.set_fullscreen(True, screen=self.screens[self.show_on])
其中
self.show_on
是显示图像的屏幕数。