odd behavior of shell editor

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

odd behavior of shell editor

Roan LaPlante
Hi,

The behavior of the Shell editor in traitsui seems to have some unintended side effects that don't make any sense to me.  I'm writing a traitsui application to visualize neuroimaging data and being able to include a shell to interact with the data in real time for debugging would be very helpful, but whenever I run commands in the shell weird things seem to happen -- for instance, all of the buttons in my program's gui have their associated events fire
A simpler toy version of the problem:

from enthought.traits.api import *
from enthought.traits.ui.api import *

class Huckleberry(HasTraits):
    pshell=PythonValue
    button1=Button('button1')

    traits_view = View(Item(name='pshell',editor=ShellEditor(),height=500,width=500),
                        Item(name='button1'))
       
    def _button1_fired(self):
        print "Pressed"
   
h=Huckleberry()
h.configure_traits()


Whenever a command is executed in the interactive shell, the _button1_fired method is called and prints to stdout.  This is true no matter what the command (for instance, the ostensibly unrelated command "print 4" results in this behavior).  Additionally, executing a command sometimes results in the following error:

Exception occurred in traits notification handler for object: <__main__.Huckleberry object at 0x2b95710>, trait: trait_added, old value: <undefined>, new value: None
Traceback (most recent call last):
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/trait_notifiers.py", line 373, in call_2
    self.handler( object, new )
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/has_traits.py", line 1485, in _trait_added_changed
    if (trait.type == 'delegate') and (name[-6:] != '_items'):
AttributeError: 'NoneType' object has no attribute 'type'


The shell isn't at all a crucial part of my program, but I wanted to send to this list to ask if anyone knows anything about this problem or if there is something I'm doing wrong to cause this buggy behavior.

thanks,
R


--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


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

Re: odd behavior of shell editor

Warren Weckesser-2


On Wed, Jan 16, 2013 at 1:55 PM, Roan LaPlante <[hidden email]> wrote:
Hi,

The behavior of the Shell editor in traitsui seems to have some unintended side effects that don't make any sense to me.  I'm writing a traitsui application to visualize neuroimaging data and being able to include a shell to interact with the data in real time for debugging would be very helpful, but whenever I run commands in the shell weird things seem to happen -- for instance, all of the buttons in my program's gui have their associated events fire
A simpler toy version of the problem:

from enthought.traits.api import *
from enthought.traits.ui.api import *

class Huckleberry(HasTraits):
    pshell=PythonValue
    button1=Button('button1')

    traits_view = View(Item(name='pshell',editor=ShellEditor(),height=500,width=500),
                        Item(name='button1'))
       
    def _button1_fired(self):
        print "Pressed"
   
h=Huckleberry()
h.configure_traits()


Whenever a command is executed in the interactive shell, the _button1_fired method is called and prints to stdout.  This is true no matter what the command (for instance, the ostensibly unrelated command "print 4" results in this behavior).  Additionally, executing a command sometimes results in the following error:

Exception occurred in traits notification handler for object: <__main__.Huckleberry object at 0x2b95710>, trait: trait_added, old value: <undefined>, new value: None
Traceback (most recent call last):
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/trait_notifiers.py", line 373, in call_2
    self.handler( object, new )
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/has_traits.py", line 1485, in _trait_added_changed
    if (trait.type == 'delegate') and (name[-6:] != '_items'):
AttributeError: 'NoneType' object has no attribute 'type'


The shell isn't at all a crucial part of my program, but I wanted to send to this list to ask if anyone knows anything about this problem or if there is something I'm doing wrong to cause this buggy behavior.



Looks like the problem is that the default value of `pshell` is None, but the ShellEditor needs a dictionary.  Change the definition of `pshell` to

        pshell = PythonValue({})

so that the default value is an empty dictionary, or even better, be more explicit and declare it to be a dict:

        pshell = Dict


Warren


thanks,
R


--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: odd behavior of shell editor

Adam Hughes
Is the button possibly mapped to enter by default?

On Wed, Jan 16, 2013 at 2:21 PM, Warren Weckesser <[hidden email]> wrote:


On Wed, Jan 16, 2013 at 1:55 PM, Roan LaPlante <[hidden email]> wrote:
Hi,

The behavior of the Shell editor in traitsui seems to have some unintended side effects that don't make any sense to me.  I'm writing a traitsui application to visualize neuroimaging data and being able to include a shell to interact with the data in real time for debugging would be very helpful, but whenever I run commands in the shell weird things seem to happen -- for instance, all of the buttons in my program's gui have their associated events fire
A simpler toy version of the problem:

from enthought.traits.api import *
from enthought.traits.ui.api import *

class Huckleberry(HasTraits):
    pshell=PythonValue
    button1=Button('button1')

    traits_view = View(Item(name='pshell',editor=ShellEditor(),height=500,width=500),
                        Item(name='button1'))
       
    def _button1_fired(self):
        print "Pressed"
   
h=Huckleberry()
h.configure_traits()


Whenever a command is executed in the interactive shell, the _button1_fired method is called and prints to stdout.  This is true no matter what the command (for instance, the ostensibly unrelated command "print 4" results in this behavior).  Additionally, executing a command sometimes results in the following error:

Exception occurred in traits notification handler for object: <__main__.Huckleberry object at 0x2b95710>, trait: trait_added, old value: <undefined>, new value: None
Traceback (most recent call last):
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/trait_notifiers.py", line 373, in call_2
    self.handler( object, new )
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/has_traits.py", line 1485, in _trait_added_changed
    if (trait.type == 'delegate') and (name[-6:] != '_items'):
AttributeError: 'NoneType' object has no attribute 'type'


The shell isn't at all a crucial part of my program, but I wanted to send to this list to ask if anyone knows anything about this problem or if there is something I'm doing wrong to cause this buggy behavior.



Looks like the problem is that the default value of `pshell` is None, but the ShellEditor needs a dictionary.  Change the definition of `pshell` to

        pshell = PythonValue({})

so that the default value is an empty dictionary, or even better, be more explicit and declare it to be a dict:

        pshell = Dict


Warren


thanks,
R


--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


_______________________________________________
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




--
Adam Hughes
Physics Ph.D Candidate
George Washington University

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

Re: odd behavior of shell editor

Roan LaPlante
In reply to this post by Warren Weckesser-2
Warren's solution works like a charm -- it would be nice if the documentation for ShellEditor indicated this more clearly.

thanks!
R

On Wed, Jan 16, 2013 at 2:21 PM, Warren Weckesser <[hidden email]> wrote:


On Wed, Jan 16, 2013 at 1:55 PM, Roan LaPlante <[hidden email]> wrote:
Hi,

The behavior of the Shell editor in traitsui seems to have some unintended side effects that don't make any sense to me.  I'm writing a traitsui application to visualize neuroimaging data and being able to include a shell to interact with the data in real time for debugging would be very helpful, but whenever I run commands in the shell weird things seem to happen -- for instance, all of the buttons in my program's gui have their associated events fire
A simpler toy version of the problem:

from enthought.traits.api import *
from enthought.traits.ui.api import *

class Huckleberry(HasTraits):
    pshell=PythonValue
    button1=Button('button1')

    traits_view = View(Item(name='pshell',editor=ShellEditor(),height=500,width=500),
                        Item(name='button1'))
       
    def _button1_fired(self):
        print "Pressed"
   
h=Huckleberry()
h.configure_traits()


Whenever a command is executed in the interactive shell, the _button1_fired method is called and prints to stdout.  This is true no matter what the command (for instance, the ostensibly unrelated command "print 4" results in this behavior).  Additionally, executing a command sometimes results in the following error:

Exception occurred in traits notification handler for object: <__main__.Huckleberry object at 0x2b95710>, trait: trait_added, old value: <undefined>, new value: None
Traceback (most recent call last):
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/trait_notifiers.py", line 373, in call_2
    self.handler( object, new )
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/has_traits.py", line 1485, in _trait_added_changed
    if (trait.type == 'delegate') and (name[-6:] != '_items'):
AttributeError: 'NoneType' object has no attribute 'type'


The shell isn't at all a crucial part of my program, but I wanted to send to this list to ask if anyone knows anything about this problem or if there is something I'm doing wrong to cause this buggy behavior.



Looks like the problem is that the default value of `pshell` is None, but the ShellEditor needs a dictionary.  Change the definition of `pshell` to

        pshell = PythonValue({})

so that the default value is an empty dictionary, or even better, be more explicit and declare it to be a dict:

        pshell = Dict


Warren


thanks,
R


--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


_______________________________________________
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


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.




--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


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

Re: odd behavior of shell editor

Adam Hughes
Warren,

Thanks for posting this example.  I have been looking for good examples using the shell editor.  


On Wed, Jan 16, 2013 at 2:42 PM, Roan LaPlante <[hidden email]> wrote:
Warren's solution works like a charm -- it would be nice if the documentation for ShellEditor indicated this more clearly.

thanks!
R

On Wed, Jan 16, 2013 at 2:21 PM, Warren Weckesser <[hidden email]> wrote:


On Wed, Jan 16, 2013 at 1:55 PM, Roan LaPlante <[hidden email]> wrote:
Hi,

The behavior of the Shell editor in traitsui seems to have some unintended side effects that don't make any sense to me.  I'm writing a traitsui application to visualize neuroimaging data and being able to include a shell to interact with the data in real time for debugging would be very helpful, but whenever I run commands in the shell weird things seem to happen -- for instance, all of the buttons in my program's gui have their associated events fire
A simpler toy version of the problem:

from enthought.traits.api import *
from enthought.traits.ui.api import *

class Huckleberry(HasTraits):
    pshell=PythonValue
    button1=Button('button1')

    traits_view = View(Item(name='pshell',editor=ShellEditor(),height=500,width=500),
                        Item(name='button1'))
       
    def _button1_fired(self):
        print "Pressed"
   
h=Huckleberry()
h.configure_traits()


Whenever a command is executed in the interactive shell, the _button1_fired method is called and prints to stdout.  This is true no matter what the command (for instance, the ostensibly unrelated command "print 4" results in this behavior).  Additionally, executing a command sometimes results in the following error:

Exception occurred in traits notification handler for object: <__main__.Huckleberry object at 0x2b95710>, trait: trait_added, old value: <undefined>, new value: None
Traceback (most recent call last):
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/trait_notifiers.py", line 373, in call_2
    self.handler( object, new )
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/has_traits.py", line 1485, in _trait_added_changed
    if (trait.type == 'delegate') and (name[-6:] != '_items'):
AttributeError: 'NoneType' object has no attribute 'type'


The shell isn't at all a crucial part of my program, but I wanted to send to this list to ask if anyone knows anything about this problem or if there is something I'm doing wrong to cause this buggy behavior.



Looks like the problem is that the default value of `pshell` is None, but the ShellEditor needs a dictionary.  Change the definition of `pshell` to

        pshell = PythonValue({})

so that the default value is an empty dictionary, or even better, be more explicit and declare it to be a dict:

        pshell = Dict


Warren


thanks,
R


--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


_______________________________________________
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


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.




--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


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




--
Adam Hughes
Physics Ph.D Candidate
George Washington University

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

Re: odd behavior of shell editor

Warren Weckesser-2


On Wed, Jan 16, 2013 at 4:12 PM, Adam Hughes <[hidden email]> wrote:
Warren,

Thanks for posting this example.  I have been looking for good examples using the shell editor.  


Thank Roan; I just suggested a fix.

Warren

 


On Wed, Jan 16, 2013 at 2:42 PM, Roan LaPlante <[hidden email]> wrote:
Warren's solution works like a charm -- it would be nice if the documentation for ShellEditor indicated this more clearly.

thanks!
R

On Wed, Jan 16, 2013 at 2:21 PM, Warren Weckesser <[hidden email]> wrote:


On Wed, Jan 16, 2013 at 1:55 PM, Roan LaPlante <[hidden email]> wrote:
Hi,

The behavior of the Shell editor in traitsui seems to have some unintended side effects that don't make any sense to me.  I'm writing a traitsui application to visualize neuroimaging data and being able to include a shell to interact with the data in real time for debugging would be very helpful, but whenever I run commands in the shell weird things seem to happen -- for instance, all of the buttons in my program's gui have their associated events fire
A simpler toy version of the problem:

from enthought.traits.api import *
from enthought.traits.ui.api import *

class Huckleberry(HasTraits):
    pshell=PythonValue
    button1=Button('button1')

    traits_view = View(Item(name='pshell',editor=ShellEditor(),height=500,width=500),
                        Item(name='button1'))
       
    def _button1_fired(self):
        print "Pressed"
   
h=Huckleberry()
h.configure_traits()


Whenever a command is executed in the interactive shell, the _button1_fired method is called and prints to stdout.  This is true no matter what the command (for instance, the ostensibly unrelated command "print 4" results in this behavior).  Additionally, executing a command sometimes results in the following error:

Exception occurred in traits notification handler for object: <__main__.Huckleberry object at 0x2b95710>, trait: trait_added, old value: <undefined>, new value: None
Traceback (most recent call last):
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/trait_notifiers.py", line 373, in call_2
    self.handler( object, new )
  File "/usr/pubsw/packages/python/epd/lib/python2.7/site-packages/traits/has_traits.py", line 1485, in _trait_added_changed
    if (trait.type == 'delegate') and (name[-6:] != '_items'):
AttributeError: 'NoneType' object has no attribute 'type'


The shell isn't at all a crucial part of my program, but I wanted to send to this list to ask if anyone knows anything about this problem or if there is something I'm doing wrong to cause this buggy behavior.



Looks like the problem is that the default value of `pshell` is None, but the ShellEditor needs a dictionary.  Change the definition of `pshell` to

        pshell = PythonValue({})

so that the default value is an empty dictionary, or even better, be more explicit and declare it to be a dict:

        pshell = Dict


Warren


thanks,
R


--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


_______________________________________________
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


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.




--
Roan LaPlante
Athinoula A. Martinos Center for Biomedical Imaging


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




--
Adam Hughes
Physics Ph.D Candidate
George Washington University

_______________________________________________
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