You are not logged in.

#1 2014-04-13 23:39:01

Alcesmire
Member
From: Gothenburg, Sweden
Registered: 2014-04-13
Posts: 5

[Solved] Problem using pyglet (Python 3)

Hi, long time lurking, new time poster.

I have had some trouble with pyglet for python3 (officially supported according to their website). I created a small script to try it out:

#!/bin/python
import pyglet

window = pyglet.window.Window(resizable=True)

@window.event
def on_draw():
    window.clear()
    pyglet.gl.glColor4f(1.0,0,0,1.0)
    pyglet.graphics.draw(2, pyglet.gl.GL_LINES,
        ('v2i', (10, 15, 30, 35))
    )

pyglet.app.run()

but after importing pyglet fine, it doesn't get through the window line. After digging a bit with ipdb3 the file chain goes:

main.py(1)<module>(4)
    window = pyglet.window.Window(resizable=True)
/usr/lib/python3.4/site-packages/pyglet/window/xlib/__init__.py(166)__init__()
    super(XlibWindow, self).__init__(*args, **kwargs)
/usr/lib/python3.4/site-packages/pyglet/window/__init__.py(562)__init__()
    self.set_visible(True)
/usr/lib/python3.4/site-packages/pyglet/window/xlib/__init__.py(578)set_visible()
    self._map()
/usr/lib/python3.4/site-packages/pyglet/window/xlib/__init__.py(418)_map()
    xlib.XNextEvent(self._x_display, e)
/usr/lib/python3.4/site-packages/pyglet/canvas/xlib.py(66)_error_handler()

And forcing said error handler to print gives a lot of X11 errors (three types) like:

X11 error: b'BadMatch (invalid parameter attributes)'
   serial: 44
  request: 1
    minor: 0
 resource: 144
Python stack trace (innermost last):

X11 error: b'BadWindow (invalid Window parameter)'
   serial: 45
  request: 1
    minor: 0
 resource: 50331651
Python stack trace (innermost last):

X11 error: b'BadDrawable (invalid Pixmap or Window parameter)'
   serial: 49
  request: 154
    minor: 3
 resource: 50331652
Python stack trace (innermost last):

I really don't know where to start actually start debugging this. Hopefully someone has some idea. If it is relevant: I use a tiling window manager (awesome), but I tried running the same code in both openbox and gnome-shell in a second X server; I have also tried the python2 version and it behaves the same as the python3 one.

And like I wrote earlier: first time poster, so if I missed any rules or placed something wrong just let me know.

Alcesmire

EDIT:
I don't know how, but suddenly it started working. I don't know if it was some update, or if installing pyglet2 through pip somehow made things work for both python2 and python3. I'm confused, but my issue is solved somehow.

Last edited by Alcesmire (2014-04-25 22:24:27)

Offline

#2 2014-04-14 00:08:47

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,548

Re: [Solved] Problem using pyglet (Python 3)

Maybe you need to install pooh-bear or honey, possibly christopher-robin. 
It looks like community has python2-pyglet and you may have to install pyglet-hg from the AUR to get python3 pyglet


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

#3 2014-04-14 00:25:10

Alcesmire
Member
From: Gothenburg, Sweden
Registered: 2014-04-13
Posts: 5

Re: [Solved] Problem using pyglet (Python 3)

nomorewindows wrote:

Maybe you need to install pooh-bear or honey, possibly christopher-robin.

Oh, you. roll

nomorewindows wrote:

It looks like community has python2-pyglet and you may have to install pyglet-hg from the AUR to get python3 pyglet

Like I wrote in the OP, I did try both the python3 (pyglet-hg) and python2 (python2-pyglet) version, but no luck with either. At first glance it seems like there must be some failure in communication between pyglet and Xlib, but I could be wrong.

Offline

#4 2014-04-14 01:05:03

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,548

Re: [Solved] Problem using pyglet (Python 3)

What is your binary calling for?  /usr/bin/python python2?


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

#5 2014-04-14 01:11:49

Alcesmire
Member
From: Gothenburg, Sweden
Registered: 2014-04-13
Posts: 5

Re: [Solved] Problem using pyglet (Python 3)

Oh, it's calling python3.

$ file `which  python`
/usr/sbin/python: symbolic link to `python3'

If I would have used the other version it would have returned an error in the imports since the python2 version of pyglet isn't installed right now (the different versions conflict, apparently).

Offline

#6 2014-04-14 01:27:22

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,548

Re: [Solved] Problem using pyglet (Python 3)

There's on significant function call difference in between python2 and 3?  Looks like you are overloading the default class function.


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

#7 2014-04-14 01:43:31

Alcesmire
Member
From: Gothenburg, Sweden
Registered: 2014-04-13
Posts: 5

Re: [Solved] Problem using pyglet (Python 3)

nomorewindows wrote:

There's on significant function call difference in between python2 and 3?  Looks like you are overloading the default class function.

I'm not sure I'm following. Care to elaborate? If we're talking command differences, python{,3,3.4} is equivalent and python{2,2.7} are equivalent.

What do you mean overloading the class function? In the python code? Most of the code is irrelevant. Only the import and the window creation matters. The first step succeeds while the window creation fails.

Offline

#8 2014-04-14 15:04:50

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [Solved] Problem using pyglet (Python 3)

Alcesmire wrote:

If it is relevant: I use a tiling window manager (awesome), but I tried running the same code in both openbox and gnome-shell in a second X server; I have also tried the python2 version and it behaves the same as the python3 one.

Is this your first time running a Pyglet application on this computer? What video driver are you using? Does it support accelerated graphics? (glxinfo | grep "direct rendering")

I ask because BOTH Pyglet 2 and 3 are failing to create a window which seem suspicious, and Pyglet requires OpenGL support.

Last edited by drcouzelis (2014-04-14 15:05:17)

Offline

#9 2014-04-14 23:19:53

Alcesmire
Member
From: Gothenburg, Sweden
Registered: 2014-04-13
Posts: 5

Re: [Solved] Problem using pyglet (Python 3)

drcouzelis wrote:

Is this your first time running a Pyglet application on this computer? What video driver are you using? Does it support accelerated graphics? (glxinfo | grep "direct rendering")

Yes, this was my first time trying to run a Pyglet application on this machine. The driver I'm using (can't remember which one) does support accelerated graphics.

$ glxinfo | grep "direct rendering"
direct rendering: Yes

I've even had OpenGL working with python3 using GLUT. So OpenGL itself is functional.

EDIT:
I don't know how, but suddenly it started working. I don't know if it was some update, or if installing pyglet2 through pip somehow made things work for both python2 and python3. I'm confused, but my issue is solved somehow.

Last edited by Alcesmire (2014-04-25 22:23:06)

Offline

Board footer

Powered by FluxBB