It's been a while since I have been able to program again, however I just tried this and the alt tab combination is not actually registered by pyglet (Windows 7).
On Saturday, December 3, 2016 at 4:46:37 PM UTC-6, [email protected] wrote: > > What you can do is capture the alt-tab keys and use > window.set_fullscreen(False) to return to the desktops native resolution, > then you could use window.minimize() to miminize it to the task bar or just > leave it around. I've tried a few other approaches using > window.on_activate() and window.on_deactivate() for when the window gains > and looses focus, though I found the results were a little janky when it > came to scaling properly, others may be able to get better results. As it > stands in my current example when you tab back the window won't be in > fullscreen mode, but a simple alt+enter solves that. Example: > > import pyglet > from pyglet.window import key > from pyglet.gl import * > > class example(pyglet.window.Window): > def __init__(self): > super(example, self).__init__(640, 480, resizable=False, > fullscreen=True, caption="Test") > self.clear() > > #fullscreen aspect ratio > self.aspect = [self.width/640.0,self.height/480.0] > > pyglet.clock.get_fps() > self.fps_display = pyglet.clock.ClockDisplay() > > pyglet.clock.schedule_interval(self.update, .01) > > > def update(self,dt): > #draw screen > self.draw() > > > def draw(self): > self.clear() > self.fps_display.draw() > > > def on_key_press(self,symbol,modifiers): > if symbol == key.ESCAPE: > self.close() > #fullscreen toggle > if symbol == key.ENTER: > if modifiers & key.MOD_ALT: > #if fullscreen off, turn on and scale the screen > if self.fullscreen == False: > window.set_fullscreen(True) > > glScalef(window.width/640.0,window.height/480.0,1.0)#2.25x, > 1.875y > self.aspect[0] = window.width/640.0 > self.aspect[1] = window.height/480.0 > print 'PONG',self.aspect > #if its on, turn it off and un-scale the screen > else: > window.set_fullscreen(False) > glScalef((window.width/640.0)/self.aspect[0],(window. > height/480.0)/self.aspect[1],1.0) > > #tab out of fullsceen > if symbol == key.TAB: > if modifiers & key.MOD_ALT: > if self.fullscreen == True: > window.set_fullscreen(False) > glScalef((window.width/640.0)/self.aspect[0],(window. > height/480.0)/self.aspect[1],1.0) > self.minimize() > > > if __name__ == '__main__': > window = example() > pyglet.app.run() > > > > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.
