dumb windows enaml issue

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

dumb windows enaml issue

Mike Sarahan
Hi guys, quick bug I found in the enaml examples.  I think this will only show up on windows, because Python on other platforms is more intelligent about converting between 32-bit ints and long ints.  Windows (perhaps numpy's ndarray on Windows) seems to always use longs for these shape members, and thus this traceback:

C:\Users\Mike\Documents\GitHub\enaml\examples\widgets>enaml-run enable_canvas.en
aml
Traceback (most recent call last):
  File "F:\Python27\Scripts\enaml-run-script.py", line 9, in <module>
    load_entry_point('enaml==0.6.3', 'console_scripts', 'enaml-run')()
  File "c:\users\mike\documents\github\enaml\enaml\runner.py", line 62, in main
    show_simple_view(component(), options.toolkit, descr)
  File "c:\users\mike\documents\github\enaml\enaml\stdlib\sessions.py", line 131
, in show_simple_view
    app.start_session('main')
  File "c:\users\mike\documents\github\enaml\enaml\qt\qt_application.py", line 8
3, in start_session
    qt_session.open(session.snapshot())
  File "c:\users\mike\documents\github\enaml\enaml\session.py", line 371, in sna
pshot
    return [window.snapshot() for window in self.windows]
  File "c:\users\mike\documents\github\enaml\enaml\widgets\window.py", line 54,
in snapshot
    snap['initial_size'] = self.initial_size
  File "c:\users\mike\documents\github\enaml\enaml\core\declarative.py", line 13
2, in _wired_getter
    _set_quiet(obj, name, val)
  File "c:\users\mike\documents\github\enaml\enaml\core\declarative.py", line 11
4, in _set_quiet
    setattr(obj, name, value)
  File "F:\Python27\lib\site-packages\traits\trait_handlers.py", line 170, in er
ror
    value )
traits.trait_errors.TraitError: The 'initial_size' trait of a Main instance must
 be a tuple of the form: (an integer >= -1, an integer >= -1), but a value of (5
12L, 512L) <type 'tuple'> was specified.


It seems kludgy to me to wrap each element of the size tuple with an int() call.  Is there a better way?

Best,
Mike


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: dumb windows enaml issue

Chris Colbert
Ugh, no bueno.

I could potentially redefine the `initial_size` to be a CoercingInstance(Size) trait, which will coerce each value to an int, but then we'd lose the range checking.

I may need to bite the bullet and define a bunch of new trait types for these things. In the interim, the easiest workaround is probably: `tuple(map(int, arr.shape))`


On Sat, Jan 5, 2013 at 2:40 PM, Mike Sarahan <[hidden email]> wrote:
Hi guys, quick bug I found in the enaml examples.  I think this will only show up on windows, because Python on other platforms is more intelligent about converting between 32-bit ints and long ints.  Windows (perhaps numpy's ndarray on Windows) seems to always use longs for these shape members, and thus this traceback:

C:\Users\Mike\Documents\GitHub\enaml\examples\widgets>enaml-run enable_canvas.en
aml
Traceback (most recent call last):
  File "F:\Python27\Scripts\enaml-run-script.py", line 9, in <module>
    load_entry_point('enaml==0.6.3', 'console_scripts', 'enaml-run')()
  File "c:\users\mike\documents\github\enaml\enaml\runner.py", line 62, in main
    show_simple_view(component(), options.toolkit, descr)
  File "c:\users\mike\documents\github\enaml\enaml\stdlib\sessions.py", line 131
, in show_simple_view
    app.start_session('main')
  File "c:\users\mike\documents\github\enaml\enaml\qt\qt_application.py", line 8
3, in start_session
    qt_session.open(session.snapshot())
  File "c:\users\mike\documents\github\enaml\enaml\session.py", line 371, in sna
pshot
    return [window.snapshot() for window in self.windows]
  File "c:\users\mike\documents\github\enaml\enaml\widgets\window.py", line 54,
in snapshot
    snap['initial_size'] = self.initial_size
  File "c:\users\mike\documents\github\enaml\enaml\core\declarative.py", line 13
2, in _wired_getter
    _set_quiet(obj, name, val)
  File "c:\users\mike\documents\github\enaml\enaml\core\declarative.py", line 11
4, in _set_quiet
    setattr(obj, name, value)
  File "F:\Python27\lib\site-packages\traits\trait_handlers.py", line 170, in er
ror
    value )
traits.trait_errors.TraitError: The 'initial_size' trait of a Main instance must
 be a tuple of the form: (an integer >= -1, an integer >= -1), but a value of (5
12L, 512L) <type 'tuple'> was specified.


It seems kludgy to me to wrap each element of the size tuple with an int() call.  Is there a better way?

Best,
Mike


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev