Ah, sorry, for some reason I read your post as "Alt+Enter". 

>From a quick look at the docs, it shows that the 
Window.set_exclusive_keyboard() mode will do what you want. 

http://pyglet.readthedocs.io/en/pyglet-1.2-maintenance/programming_guide/keyboard.html?highlight=set_exclusive_keyboard#keyboard-exclusivity



On Thursday, January 12, 2017 at 7:36:37 AM UTC+9, Charles wrote:
>
> Hey Benjamin, ALT + ENTER does work, just ALT + TAB doesn't. I'm thinking 
> Windows switches out of the window pyglet gets a chance to see the 
> keypresses. 
>
> On Monday, January 9, 2017 at 1:11:07 AM UTC-6, Benjamin Moran wrote:
>>
>> Pyglet doesn't capture any keypresses by default, but I usually just add 
>> the additional events like so:
>> @window.event
>> def on_key_press(key, mod):
>>     if key == pyglet.window.key.ENTER and mod == pyglet.window.key.
>> MOD_ALT: 
>>         ......
>>         ......
>>
>>         if window.fullscreen is True:
>>             window.set_fullscreen(fullscreen=False)
>>         else:
>>             window.set_fullscreen(fullscreen=True)
>>
>>
>>
>>
>>
>> On Monday, January 9, 2017 at 8:18:53 AM UTC+9, Charles wrote:
>>>
>>> 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.

Reply via email to