[visionegg] Re: upgrading code to work with 0.99...

  • From: "Andrew Straw" <andrew.straw@xxxxxxxxxxxxxxx>
  • To: visionegg@xxxxxxxxxxxxx
  • Date: Sun, 1 Feb 2004 21:41:29 +1030 (CST)

Hi Mark,

Getting pretty formatting out of the Python error checking is an artform,
and one I'm not very good at!  Delving in, though, I think the error is
pretty simple.  (And, to my pleasure, I think the error message is nearly
as informative as it reasonably could be.)

It looks like your code attempted to use a string as the callback for
pygame.locals.QUIT. However, a callable (function) is required.  The error
reformatted for a bit more clarity is:

TypeError: Parameter 'handle_event_callbacks' value
[ (12, 'Use Ctrl-D i.e. EOF) to exit.'),
  (5, <bound method ButtonDown.click of
     <__main__.ButtonDowninstance at 0x27ae9e0>>),
  (6, <function mouse_button_up at 0x279c2b0>),
  (2,<function keydown at 0x279c2f0>),
  (3, <function keyup at 0x279c3b0>)]
is type <type 'list'> (not type
Sequence of
  Sequence2 of
    AnyOf(Integer or Callable))
in <VisionEgg.FlowControl.Presentation object at 0x27aea08>

It looks like you've got callbacks working for the other keys, so this
seems only a slip, probably (re)assigning the variable "quit" to a string
instead of a function.

Cheers!
Andrew

> Hi Andrew,
>
> I'm upgrading my code to work with 0.99, and I've played around with this
> error for a while now, and I'm stumped.
>
> I suspect I fell afoul of the new type check system, but you'll probably
> see
> immediately what needs to be changed to make this code 0.99 compliant:
>
> handle_evenhandle_event_callbacks = [(pygame.locals.QUIT, quit),
>                           (pygame.locals.MOUSEBUTTONDOWN,
> button_down.click),
>                           (pygame.locals.MOUSEBUTTONUP, mouse_button_up),
>                           (pygame.locals.KEYDOWN, keydown),
>                           (pygame.locals.KEYUP, keyup)]
>
> setup = Presentation(go_duration=('forever',),
> viewports=[viewportforsetup,
> left_mask, bracketviewport],
> handle_event_callbacks=handle_event_callbacks)
>
> The error message I get is as below:
>
> Traceback (most recent call last):
>   File "controlprotocol9.py", line 494, in ?
>     setup = Presentation(go_duration=('forever',),
> viewports=[viewportforsetup, left_mask, bracketviewport],
> handle_event_callbacks=handle_event_callbacks)
>   File
> "/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packag
> es/VisionEgg/FlowControl.py", line 145, in __init__
>     VisionEgg.ClassWithParameters.__init__(self,**kw)
>   File
> "/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packag
> es/VisionEgg/__init__.py", line 325, in __init__
>     raise TypeError("Parameter '%s' value %s is type %s (not type %s) in
> %s"%(parameter_name,value_str,type(value),tipe,self))
> TypeError: Parameter 'handle_event_callbacks' value [(12, 'Use Ctrl-D
> (i.e.
> EOF) to exit.'), (5, <bound method ButtonDown.click of
> <__main__.ButtonDown
> instance at 0x27ae9e0>>), (6, <function mouse_button_up at 0x279c2b0>),
> (2,
> <function keydown at 0x279c2f0>), (3, <function keyup at 0x279c3b0>)] is
> type <type 'list'> (not type Sequence of Sequence2 of AnyOf(Integer or
> Callable)) in <VisionEgg.FlowControl.Presentation object at 0x27aea08>
>
> As always, thanks so much for your help!
>
> Mark
======================================
The Vision Egg mailing list
Archives: //www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: