[traits] ShellEditor & Button traits conflict...

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

[traits] ShellEditor & Button traits conflict...

fred-2
Hi all,

In the following CME,
when Enter is pressed in the python shell,
the button pressed event is fired!

Which is not I really want, of course...

I also get this traceback:

Exception occurred in traits notification handler.
Please check the log file for details.
Exception occurred in traits notification handler for object:
<__main__.MyClass object at 0x914e65c>, trait: trait_added, old value:
<undefined>, new value: None
Traceback (most recent call last):
   File
"/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r25876-py2.6-linux-i686.egg/enthought/traits/trait_notifiers.py",
line 351, in call_2
     self.handler( object, new )
   File
"/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r25876-py2.6-linux-i686.egg/enthought/traits/has_traits.py",
line 1460, in _trait_added_changed
     if (trait.type == 'delegate') and (name[-6:] != '_items'):
AttributeError: 'NoneType' object has no attribute 'type'
Button fired!!!

Any clue?

What am doing wrong?

TIA.

Cheers,

--
Fred

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

Cme.py (676 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [traits] ShellEditor & Button traits conflict...

fred-2
Le 28/10/2010 15:07, Fred a écrit :

> Hi all,
>
> In the following CME,
> when Enter is pressed in the python shell,
> the button pressed event is fired!
>
> Which is not I really want, of course...
>
> I also get this traceback:
>
> Exception occurred in traits notification handler.
> Please check the log file for details.
> Exception occurred in traits notification handler for object:
> <__main__.MyClass object at 0x914e65c>, trait: trait_added, old value:
> <undefined>, new value: None
> Traceback (most recent call last):
> File
> "/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r25876-py2.6-linux-i686.egg/enthought/traits/trait_notifiers.py",
> line 351, in call_2
> self.handler( object, new )
> File
> "/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r25876-py2.6-linux-i686.egg/enthought/traits/has_traits.py",
> line 1460, in _trait_added_changed
> if (trait.type == 'delegate') and (name[-6:] != '_items'):
> AttributeError: 'NoneType' object has no attribute 'type'
> Button fired!!!
>
> Any clue?
>
> What am doing wrong?
Hi all,

Nobody has any clue on this issue?? :-/


Cheers,

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

Re: [traits] ShellEditor & Button traits conflict...

Corran Webster
In reply to this post by fred-2
Hi Fred,

I had a quick look into it, the problem is that a ShellEditor expects a Dict, not a String, as the trait it is editing.  The contents of the Dict is the namespace of the shell:

class MyClass(HasTraits):   
    shell = Dict
    ...

works for me.

-- Corran

On Thu, Oct 28, 2010 at 8:07 AM, Fred <[hidden email]> wrote:
Hi all,

In the following CME,
when Enter is pressed in the python shell,
the button pressed event is fired!

Which is not I really want, of course...

I also get this traceback:

Exception occurred in traits notification handler.
Please check the log file for details.
Exception occurred in traits notification handler for object: <__main__.MyClass object at 0x914e65c>, trait: trait_added, old value: <undefined>, new value: None
Traceback (most recent call last):
 File "/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r25876-py2.6-linux-i686.egg/enthought/traits/trait_notifiers.py", line 351, in call_2
   self.handler( object, new )
 File "/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r25876-py2.6-linux-i686.egg/enthought/traits/has_traits.py", line 1460, in _trait_added_changed
   if (trait.type == 'delegate') and (name[-6:] != '_items'):
AttributeError: 'NoneType' object has no attribute 'type'
Button fired!!!

Any clue?

What am doing wrong?

TIA.

Cheers,

--
Fred

_______________________________________________
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: [traits] ShellEditor & Button traits conflict...

fred-2
Le 02/11/2010 16:03, Corran Webster a écrit :

> Hi Fred,
>
> I had a quick look into it, the problem is that a ShellEditor expects a
> Dict, not a String, as the trait it is editing.  The contents of the
> Dict is the namespace of the shell:
>
> class MyClass(HasTraits):Â Â Â
> Â Â Â  shell = Dict
> Â Â Â  ...
>
> works for me.
Thanks a lot, Corran!

I used a Str because I stopped at the first occurrence of "ShellEditor"
in the e-dev ml archives, and this occurrence was using a Str, not a Dict.

I should have UTSL, I agree :-/


Cheers,

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

Re: [traits] ShellEditor & Button traits conflict...

bryce hendrix-2
In reply to this post by fred-2


On Tue, Nov 2, 2010 at 9:36 AM, Fred <[hidden email]> wrote:
Le 28/10/2010 15:07, Fred a écrit :
> Hi all,
>
> In the following CME,
> when Enter is pressed in the python shell,
> the button pressed event is fired!
>
> Which is not I really want, of course...
>
> I also get this traceback:
>
> Exception occurred in traits notification handler.
> Please check the log file for details.
> Exception occurred in traits notification handler for object:
> <__main__.MyClass object at 0x914e65c>, trait: trait_added, old value:
> <undefined>, new value: None
> Traceback (most recent call last):
> File
> "/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r25876-py2.6-linux-i686.egg/enthought/traits/trait_notifiers.py",
> line 351, in call_2
> self.handler( object, new )
> File
> "/usr/local/lib/python2.6/dist-packages/Traits-3.5.1.dev_r25876-py2.6-linux-i686.egg/enthought/traits/has_traits.py",
> line 1460, in _trait_added_changed
> if (trait.type == 'delegate') and (name[-6:] != '_items'):
> AttributeError: 'NoneType' object has no attribute 'type'
> Button fired!!!
>
> Any clue?
>
> What am doing wrong?
Hi all,

Nobody has any clue on this issue?? :-/

I suspect the OK button is bound to enter key press. Try removing the buttons argument and adding an Item('b') instead.

Bryce

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

Re: [traits] ShellEditor & Button traits conflict...

fred-2
In reply to this post by fred-2
Another question: one can use a python shell within a ShellEditor but
_not_ ipython shell, right?


I would like very much to use ipython rather than python.


Cheers,

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

Re: [traits] ShellEditor & Button traits conflict...

Corran Webster
On Tue, Nov 2, 2010 at 4:15 PM, Fred <[hidden email]> wrote:
Another question: one can use a python shell within a ShellEditor but
_not_ ipython shell, right?


I would like very much to use ipython rather than python.


Not out of the box in Traits, I believe, because we don't have iPython support for Qt, only Wx right now.  However, if you are using Wx prepared to do a little work, you can get an iPython shell.  The approaches you can take:

* subclass the ShellEditor so that it uses an IPythonWidget instead of a PythonShell widget at the PyFace level.
* drop down to PyFace and use the shell directly, without the TraitsGUI infrastructure
* go up one level, and use Envisage and its iPythonShell plugin.

Bryce may be able to add something to the idea of using the PyFace level - I haven't ever used that layer myself.  I have used the Envisage layer, but it requires a bit of re-thinking the way that you write your app.

The iPython folks put in a fair amount of effort over the summer to make it easier to safely run an iPython prompt in a separate process so that it doesn't being down your app if the user types in a command that blows things up (runs forever, etc.), so it may be worth waiting a bit for those improvements to percolate into Traits.

-- Corran

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

Re: [traits] ShellEditor & Button traits conflict...

fred-2
Le 03/11/2010 15:32, Corran Webster a écrit :
> On Tue, Nov 2, 2010 at 4:15 PM, Fred <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Another question: one can use a python shell within a ShellEditor but
>     _not_ ipython shell, right?
>
>
>     I would like very much to use ipython rather than python.

[snip]

> The iPython folks put in a fair amount of effort over the summer to make
> it easier to safely run an iPython prompt in a separate process so that
> it doesn't being down your app if the user types in a command that blows
> things up (runs forever, etc.), so it may be worth waiting a bit for
> those improvements to percolate into Traits.
Ok, thanks for the info, Corran.

Cheers,

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

Re: [traits] ShellEditor & Button traits conflict...

bryce hendrix-2
In reply to this post by Corran Webster
On Wed, Nov 3, 2010 at 10:32 AM, Corran Webster <[hidden email]> wrote:
On Tue, Nov 2, 2010 at 4:15 PM, Fred <[hidden email]> wrote:
Another question: one can use a python shell within a ShellEditor but
_not_ ipython shell, right?


I would like very much to use ipython rather than python.


Not out of the box in Traits, I believe, because we don't have iPython support for Qt, only Wx right now.  However, if you are using Wx prepared to do a little work, you can get an iPython shell.  The approaches you can take:

* subclass the ShellEditor so that it uses an IPythonWidget instead of a PythonShell widget at the PyFace level.
* drop down to PyFace and use the shell directly, without the TraitsGUI infrastructure
* go up one level, and use Envisage and its iPythonShell plugin.

Bryce may be able to add something to the idea of using the PyFace level - I haven't ever used that layer myself.  I have used the Envisage layer, but it requires a bit of re-thinking the way that you write your app.

I've never got IPython working all that well in the Shell. Evan had spent some time in 2009 trying to get it working, with limited success. I think you're better off buying your way into the hearts of the IPython guys and working with them to get a solution based on their latest efforts.

Bryce

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

Re: [traits] ShellEditor & Button traits conflict...

fred-2
Le 03/11/2010 22:43, bryce hendrix a écrit :

> I've never got IPython working all that well in the Shell. Evan had
> spent some time in 2009 trying to get it working, with limited success.
> I think you're better off buying your way into the hearts of the IPython
> guys and working with them to get a solution based on their latest efforts.
Ok, Bryce, I'm a patient guy ;-)

BTW, this is _really_ cool to have access to all my class's traits in a
python shell so easily. I was thinking it would be more difficult to
achieve this.


Cheers,

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