Shady El Damaty | 20 Oct 06:09 2014
Picon

Major Problems with Pyglet for PsychoPy

Hello,

I am trying to use pyglet with psychopy to create a psychology experiment but am running into all sorts of issues.

I used macports to install python2.6 and psychopy in /opt/local/bin/python2.6 on OS X 10.9

I'm running everything in pyCharm using the python interperter in /opt/local/bin.  

I've also installed pyglet 1.2alpha1 and updated XQuartz to the newest version.

If I try to run 

from pyglet.window import Window

I see that python tries to launch but nothing happens.

Typing 

from pyglet import app
app.run()

Just freezes up the terminal (the prompt disappears)

All I want is for this simple code to run:
from psychopy import core, visual
import pyglet

#Create a window
win = visual.Window([400,300])
#Create a stimulus for a certain window
message = visual.TextStim(win, text='Hello World!')
# Draw the stimulus to the window
message.draw()
# Flip backside of the window
win.flip()
#Pause 5s so you get a chance to see it
core.wait(5.0)

But I get this error message:
/opt/local/bin/python2.6 /Users/shadyeldamaty/PycharmProjects/ultimatgame/psypy1.py
/Users/shadyeldamaty/.local/lib/python2.6/site-packages/psychopy/visual/helpers.py:176: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  if color==None:
Traceback (most recent call last):
  File "/Users/shadyeldamaty/PycharmProjects/ultimatgame/psypy1.py", line 14, in <module>
    win = visual.Window([400,300])
  File "/Users/shadyeldamaty/.local/lib/python2.6/site-packages/psychopy/visual/window.py", line 320, in __init__
    self._setupGL()
  File "/Users/shadyeldamaty/.local/lib/python2.6/site-packages/psychopy/visual/window.py", line 1338, in _setupGL
    self._setupPyglet()
  File "/Users/shadyeldamaty/.local/lib/python2.6/site-packages/psychopy/visual/window.py", line 1212, in _setupPyglet
    self._hw_handle=self.winHandle._window.value
AttributeError: 'CocoaWindow' object has no attribute '_window'
1.6892 WARNING Creating new monitor...
1.6894 WARNING Creating new monitor...

Process finished with exit code 1

I've tried running the above code in 32bit mode in Canopy with arch -386 python and this doesn't work either.

from pyglet import app

app.run()
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-14-810b1526bc66> in <module>()
----> 1 app.run()

/Users/shadyeldamaty/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyglet/__init__.py in __getattr__(self, name)
    304 
    305             import_name = 'pyglet.%s' % self._module_name
--> 306             __import__(import_name)
    307             module = sys.modules[import_name]
    308             object.__setattr__(self, '_module', module)

/Users/shadyeldamaty/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyglet/app/__init__.pyc in <module>()
    289 
    290     if sys.platform == 'darwin':
--> 291         from pyglet.app.carbon import CarbonEventLoop as EventLoop
    292     elif sys.platform in ('win32', 'cygwin'):
    293         from pyglet.app.win32 import Win32EventLoop as EventLoop

/Users/shadyeldamaty/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyglet/app/carbon.py in <module>()
     42 
     43 from pyglet.app import windows, BaseEventLoop
---> 44 from pyglet.window.carbon import carbon, types, constants, _oscheck
     45 
     46 EventLoopTimerProc = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p)

/Users/shadyeldamaty/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyglet/window/__init__.py in <module>()
   1667     # Try to determine which platform to use.
   1668     if sys.platform == 'darwin':
-> 1669         from pyglet.window.carbon import CarbonPlatform, CarbonWindow
   1670         _platform = CarbonPlatform()
   1671         Window = CarbonWindow

/Users/shadyeldamaty/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyglet/window/carbon/__init__.py in <module>()
     47 from pyglet.window import WindowException, Platform, Display, Screen,      48     BaseWindow, MouseCursor, DefaultMouseCursor, _PlatformEventHandler
---> 49 from pyglet.window import key
     50 from pyglet.window import mouse
     51 from pyglet.window import event

ImportError: cannot import name key 


Can you please help me debug why pyglet will not work on my system and if possible how to get the psychopy script above to work?  I've been working on this issue for about 8 hours now and have tried everything I could find online.  

--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Vim | 14 Oct 22:26 2014
Picon

Pyglet 1.2+ on PyPi

Hi all,

What steps need to be taken in order to get a more recent version of pyglet onto PyPi for easy installation via pip? Getting the package into a conda repository would be even better.

If this is something simple to do, please point me in the right direction.

If this is something difficult to do, when do we plan on updating these package manager repos next?

--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Ryan Hughes | 14 Oct 17:38 2014
Picon

Vsync doesn't work.

Hi.

I'm trying to get pyglet set up, but I can't seem to get vsync to work at all.

window.set_vsync(True) does nothing as far as I can tell (as well as window.set_vsync(False)).

My application still runs at ~120 FPS either way (note my refresh rate is 60Hz).

I'm at a loss as to what is going on. I've had similar problems in the past, but nothing seems to work here. Do you have any suggestions?

I'm running Linux Mint 14, with an Nvidia GTX 660M, pyglet 1.2a, and Python 3.4.

Here's my code: http://pastie.org/9647387


--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Robert Stolarz | 12 Oct 23:01 2014
Picon

Drawing vertex lists in Pyglet

I'm trying to draw some objects in Pyglet using the same Vertex List and transforming; unfortunately, I can't get the shape to appear on my screen. Why can't I see it? Is this a good way to draw the same shape in different places with different colors?

from pyglet.gl import *
from pyglet.graphics import *


class PointySide:
    neither
= 0
    left
= 1
    right
= 2
    both
= 3


v_lists
= {}
def getVList(psTup):
   
if psTup in v_lists:
       
return v_lists[psTup];
    vs
= (0,0,3,0)
   
for i,v in enumerate(psTup):
       
if v & PointySide.right:
            vs
= vs + (4,i*4+2)
        vs
= vs + (3,i*4+4)
   
   
for i,v in enumerate(psTup[::-1]): # in reverse now
        vs
= vs + (0,i*4)
       
print v
       
if v & PointySide.left:
            vs
= vs + (1,i*4+2)
   
    v_lists
[psTup] = vs
   
return vs


# Direct OpenGL commands to this window.
window
= pyglet.window.Window()


t
= (PointySide.both,PointySide.left)
l
= getVList(t)
pointsnum
= len(l)/2
vertex_list
= pyglet.graphics.vertex_list(pointsnum,
   
('v2i/static',l),
   
('c3b/static',(255,0,0) * pointsnum) # * repeats a tuple, because python
)


<at> window.event
def on_draw():
    glClear
(GL_COLOR_BUFFER_BIT)
    glLoadIdentity
()
    glPushMatrix
()
    glTranslatef
(-10,-60,0)
   
#glScalef(2,2,1)
     
# # #
    pyglet
.graphics.draw_indexed(4, pyglet.gl.GL_TRIANGLES,
   
[0, 1, 2, 0, 2, 3],
   
('v2i', (100, 100,
             
150, 100,
             
150, 150,
             
100, 150))
   
)


    vertex_list
.draw(GL_POLYGON);
    glPopMatrix
()
   


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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
John Ladasky | 10 Oct 01:40 2014
Picon
Picon

Pyglet tests, and 2to3

Hi folks,

I just set up a new OS (Windows 7, in case it matters), and installed Pyglet 1.2 alpha1 on Python 3.4.  In doing so, I was reminded of an issue that I encountered the last time I did a Pyglet installation.  While the Pyglet docs state that 2to3 is automatically run on Pyglet itself during the installation process, it would appear that the files in the "tests" directory are NOT similarly converted.  Is this intentional?  If not, would it be difficult to fix that?  Thanks for considering my suggestion.

--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Vim | 5 Oct 15:41 2014
Picon

What other GUI libraries can Pyglet play "nicely" with?

I have interest in using the following libraries with Pyglet:

matplotlib - Plotting data produced during simulation

Tkinter - Editing drop-down menus

Kytten - Nicer widgets (buttons, text boxes, etc.)


I would like to do all of these things within a pyglet window if possible. Is this possible? I've only found that this can be done with matplotlib via stack overflow so far.

As for Tkinter and Kytten, if there are better ways to do these things via Pyglet or other libraries, I'd be happy to learn about them. I am a bit reluctant to use kytten, as it hasn't had a commit in over 3 years... I suppose Cocos2d for python may be another alternative if it can play nicely with Pyglet.

Thanks!

--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
buynnnmmm1 | 3 Oct 14:53 2014
Picon

I cannot exec pyglet.resrouce.image("hogehoge") with 1.2alpha, How can I do this?

I cannot exec pyglet.resrouce.image("hogehoge") with 1.2alpha, How can I do this?

I can do it with version 1.1.4 pyglet.

pyglet.resource.path is ['.'], and I try to load a png file in current directory.
I can do it with version 1.1.4 pyglet of Debian package.

I would like to use Cocos2D package.

It requires Pyglet version 1.2alpha.

Is there patch to collect it?


My machine:
OS: Debian Linux Sid
Python version 2.7 and 3.4 (selectable)
Debian Pyglet package version 1.1.4
pip install Pyglet version 1.2alpha ( --user install )



With best regards
buynnnmmm1

--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Vim | 30 Sep 14:37 2014
Picon

Preferred method for obtaining monitor(s) dimensions in pixels for GNU/Linux, Mac OS X, and Windows?

Hi All,

Been using Pyglet for almost a week now and loving it. I've been struggling with handling window dimensions lately. Apologies if this does not belong on the Pyglet mailing list, as the solution may not involve using Pyglet.

I've searched Stackoverflow quite extensively and have found many direct and indirect methods of finding monitor dimensions on various platforms. A lot of these methods seem very hacky to me, e.g. create TKinter GUI, maximize it, and grab dimensions. I've actually tried this example, and it only works some times because Tkinter seems to choose a different monitor sometime (dual monitors), and I get the wrong dimensions.

What is methods do you all use to grab monitor dimensions? Or should I not even have to worry about window dimensions? I wanted to grab window dimensions, and scale the window size accordingly (window width,height = 1/2 (monitor width, height) by default). Maybe I should just stick to hard-coded dimensions, and allow fullscreen.

--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Jose Luis Da | 23 Sep 16:02 2014

Abort Trap: when using a Python script with Tkinter and Pyglet

I have written a Python script which uses Pyglet for the main window and Tkinter for an initial GUI window. This script works as expected on Windows, i.e. it shows the Tkinter GUI window and the Pyglet animation. However, it does not run properly on a Mac, I am not able to make both windows work together, they do work separately.

I have found that the error arises when the line `master = Tk()` is executed, if the following libraries has been imported 

    from pyglet.gl import *
    from pyglet.window import Window, mouse, key

The complete code I am using for testing this is:

    import pyglet
    from pyglet.gl import *
    from pyglet.window import Window, mouse, key
    from Tkinter import * # for the subject data gui
    
    master = Tk()



And the error message I get from it is the following:

    Python[1359:60f] -[NSApplication _setup:]: unrecognized selector sent to instance 0x10300adb0
    Python[1359:60f] An uncaught exception was raised
    ython[1359:60f] -[NSApplication _setup:]: unrecognized selector sent to instance 0x10300adb0
    Python[1359:60f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x10300adb0'
    *** Call stack at first throw:
    (
    0   CoreFoundation                      0x00007fff8685b7b4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x00007fff84e2c0f3 objc_exception_throw + 45
    2   CoreFoundation                      0x00007fff868b5110 +[NSObject(NSObject) doesNotRecognizeSelector:] + 0
    3   CoreFoundation                      0x00007fff8682d91f ___forwarding___ + 751
    4   CoreFoundation                      0x00007fff86829a68 _CF_forwarding_prep_0 + 232
    5   Tk                                  0x0000000116cc2b24 TkpInit + 545
    6   Tk                                  0x0000000116c389ee Initialize + 1648
    7   _tkinter.so                         0x0000000116af6c0d Tcl_AppInit + 77
    8   _tkinter.so                         0x0000000116af5657 Tkinter_Create + 919
    9   Python                              0x00000001000c2fad PyEval_EvalFrameEx + 21405
    10  Python                              0x00000001000c4fb3 PyEval_EvalCodeEx + 2115
    11  Python                              0x000000010003eac0 function_call + 176
    12  Python                              0x000000010000ceb2 PyObject_Call + 98
    13  Python                              0x000000010001f56d instancemethod_call + 365
    14  Python                              0x000000010000ceb2 PyObject_Call + 98
    15  Python                              0x00000001000bc957 PyEval_CallObjectWithKeywords + 87
    16  Python                              0x000000010002285e PyInstance_New + 126
    17  Python                              0x000000010000ceb2 PyObject_Call + 98
    18  Python                              0x00000001000c0c60 PyEval_EvalFrameEx + 12368
    19  Python                              0x00000001000c4fb3 PyEval_EvalCodeEx + 2115
    20  Python                              0x00000001000c50d6 PyEval_EvalCode + 54
    21  Python                              0x00000001000e995e PyRun_FileExFlags + 174
    22  Python                              0x00000001000e9bfa PyRun_SimpleFileExFlags + 458
    23  Python                              0x0000000100100c0d Py_Main + 3101
    24  Python                              0x0000000100000f14 0x0 + 4294971156
    25  ???                                 0x0000000000000002 0x0 + 2
    )
    terminate called after throwing an instance of 'NSException'
    Abort trap 


I do not understand what this error means, can anyone help me understand what have I done wrong?

--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Cloud Strife | 12 Sep 18:42 2014
Picon

Display errors.

Whenever I run the astraea.py example, the display is messed up.
The arrows don't have transparent backgrounds. Shots don't show up (although they are being fired at
asteroids). Explosions show up sometimes and then stop. The asteroid image may hang after being shot,
then spliting afterwards.
What could have caused this?

--

-- 
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

feenuks | 6 Sep 18:23 2014
Picon

Pyglet player

I have code like this:
import pyglet

class Video():
   
def __init__(self, engine):
       
self._engine = engine
       
self._player = pyglet.media.Player()

   
<at> property
   
def window(self):
       
return self._engine.window

   
def play(self, filename):
       
def on_draw():
           
self.window.clear()
           
print('video on draw')
           
if self._player.source and self._player.source.video_format:
               
self._player.get_texture().blit(0, 0)


        source
= pyglet.media.load(filename, streaming=True)
       
self._player.push_handlers(on_eos, on_player_eos)
       
self._player.queue(source)
       
self._player.play()
       
self.window.push_handlers(on_draw)

class Engine():
   
def __init__(self):
       
self.window = pyglet.window.Window()
       
self.video = Video(self)
   
def show_menu(self):
        image
= pyglet.image.load('some/file.jpg')
       
<at> self.window.event
       
def on_draw():
           
self.window.clear()
            image
.blit(0, 0)

e
= Engine()
e
.video.play('some/movie.avi')
e
.show_menu()
pyglet
.app.run()

I have problem with video player. How can I made it to block executing rest of code until video ends (i.e. e.show_menu() is called after whole movie is played). Any suggestions? Thank you.
Tutaj wprowadź kod...

--
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 pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Gmane