I'm writing a simple image viewer and got to the point where I want to switch between displays.
I have a method that renders an image, inside there is:
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'
I want to redraw a window, but due to fact that I need to initialize pyglet.window.Window
earlier. When I window.close()
and then initialize it over it complains about pyglet.gl.ContextException: Unable to share contexts.
My guess it's because there is one window already (although pyglet context documentation states that each window has it's own context
.
Is there a way to update screen attribute of Window
without (or with) recreating it?
To move window to another screen we need:
self.window.set_fullscreen(True, screen=self.screens[self.show_on])
where self.show_on
is number of screen to display image.