Hi, I just came across a problem when running the latest Pyglet in Sublime 
Text. I also have a potential fix.

If you open Sublime Text with the following code, save it as 'test.py', and 
build with Ctrl+B, the window is never shown. "Running" gets written to the 
console and there's a background Python process, but with no visible 
windows. Running test.py from the command line works fine.


import pyglet
game_window = pyglet.window.Window()

if __name__ == '__main__':

              print 'Running' 

    pyglet.app.run()


I walked through the Pyglet code and it seems that ShowWindow wasn't 
actually showing the window. Having done low-level Windows programming in 
the past, I tried using SetWindowsPos instead and that seemed to fix the 
problem in both environments.

Is there anywhere to submit a patch or pull request? I do use Mercurial, 
but honestly, I'm not quite sure what the protocol is outside of Github. To 
fix the problem, I changed the pyglet/window/win32/__init__.py file, in the 
set_visible function (line 600), from:

    def set_visible(self, visible=True):
        if visible:
            if self._fullscreen:
                _user32.SetWindowPos(self._hwnd, HWND_TOPMOST, 0, 0, 0, 0,
                    SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW)
            else:
                _user32.ShowWindow(self._hwnd, SW_SHOW)

to

    def set_visible(self, visible=True):
        if visible:
            insertAfter = HWND_TOPMOST if self._fullscreen else HWND_TOP
            _user32.SetWindowPos(self._hwnd, insertAfter, 0, 0, 0, 0,
                SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW)

Any contribution help or further insight is appreciated.

Joe

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pyglet-users/-/4B82nrbhk3cJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to