ipython/ipdb & traits question

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

ipython/ipdb & traits question

_jelle_
Hi,

A bad habit I've developed is dropping into (i)pdb all too often.
When I do so when trying to build a GUI with traits, many things happen,
except seeing a shiny tab completing debugger shell.
Perhaps this is a silly question and maybe I shouldn't expect this to happen.
If so, what would be an effective way of debugging TraitsGUI apps?

Thanks,

-jelle

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

Traits & MenuBar

Boiteux, Benoit
Hello,

I created a view where I'd like to add a menubar.
I tried to use Traits User manual, but this one seems out of date since Action class doesn't contain any 'action' attribute anymore.

My view is like:
View(
        Item('myitem'),
        ...
      menubar = MenuBar(
                                Menu('exit_action', name='&File'),
                               
                                )
)

And I defined exit_action in the constructor of the HasTraits class:
 
self.exit_action = Action(name='E&xit', on_perform=self.close)

but Exit item doesn't appear.

What is the rule to create toolbar and menubar in a view ?

Thanks
Benoit
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

Re: Traits & MenuBar

Boiteux, Benoit
Hello,

I changed my code and tried this:

_my_action = Instance(Action)
_tool_bar = Instance(toolBar)


view = View(
        Item('myitem'),
        ...
      toolbar = '_tool_bar'
)

def __my_action_default(self):
    Return Action (name = 'MyAction',
                   on_perform = self.do_action,
                   enabled = True)

def __tool_bar_default(self):
    m = ToolBar(
                self._my_action,
                show_tool_names = False
            )
    return m


But the toolbar doesn't appear...
Any idea?

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Boiteux, Benoit
Sent: Friday, February 12, 2010 3:19 PM
To: [hidden email]
Subject: [Enthought-Dev] Traits & MenuBar

Hello,

I created a view where I'd like to add a menubar.
I tried to use Traits User manual, but this one seems out of date since Action class doesn't contain any 'action' attribute anymore.

My view is like:
View(
        Item('myitem'),
        ...
      menubar = MenuBar(
                                Menu('exit_action', name='&File'),
                               
                                )
)

And I defined exit_action in the constructor of the HasTraits class:
 
self.exit_action = Action(name='E&xit', on_perform=self.close)

but Exit item doesn't appear.

What is the rule to create toolbar and menubar in a view ?

Thanks
Benoit
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

Re: ipython/ipdb & traits question

Robert Kern
In reply to this post by _jelle_
On Fri, Feb 12, 2010 at 05:57, jelle <[hidden email]> wrote:
> Hi,
>
> A bad habit I've developed is dropping into (i)pdb all too often.
> When I do so when trying to build a GUI with traits, many things happen,
> except seeing a shiny tab completing debugger shell.
> Perhaps this is a silly question and maybe I shouldn't expect this to happen.
> If so, what would be an effective way of debugging TraitsGUI apps?

Exactly what are you trying to do? Are you using pdb.set_trace()? Or
are you trying to catch exceptions in the debugger? If the latter, one
thing to be aware of is that Traits catches and logs exceptions in
Trait event notifications (i.e. almost all the time in a Traits UI
app). pdb will never see the exception. You can change this like so:

  from enthought.traits.api import push_exception_handler

  push_exception_handler(reraise_exceptions=True)

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Traits & MenuBar

Boiteux, Benoit
In reply to this post by Boiteux, Benoit
Hi again,

Traits and Menubar/Toolbar starts making me crazy :)

I have the following code (part of a HasTraits)
    class MyHandler(Handler):
        def do_record_action(self,UIInfo):
            return
       
        record_action = Action(name = "Record",action = 'do_record_action')
   
    view = View(
                HSplit(
                       Item('proj', show_label = False, editor=InstanceEditor(view='chan_conf_view'), style='custom'),
                       Item('plot', show_label = False, editor=ComponentEditor()),
                       Item('proj', show_label = False, editor=InstanceEditor(view='chan_meas_view'), style='custom'),
                       ),
                toolbar = ToolBar(record_action),
                menubar = MenuBar(Menu(record_action,name="Record")),
                icon = ImageResource('../PowerAnalyzer.ico'),
                title="Power Analyzer v0.5",
                resizable = True,
                width = 1280,
                height = 900,
                handler = MyHandler()              
                )

If I use wx backend, menubar and toolbar appear correctly
If I use qt backend, toolbar doesn't appear at all and menubar has "Record" with a blank menu item...
Is it a bug or I did something wrong ?

Then, with wx backup, If I click on the toolbar, I have:
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\pyface\ui\wx\action\action_item.py", line 473, in _on_tool
    self.controller.perform(action)
  File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\traits\ui\wx\ui_base.py", line 282, in perform
    self.ui.do_undoable( self._perform, action )
  File "C:\Python26\lib\site-packages\traits-3.2.0-py2.6-win32.egg\enthought\traits\ui\ui.py", line 704, in do_undoable
    action( *args, **kw )
  File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\traits\ui\wx\ui_base.py", line 298, in _perform
    action.perform()
TypeError: perform() takes exactly 2 arguments (1 given)

Any idea ?

Thanks
benoit

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Boiteux, Benoit
Sent: Monday, February 15, 2010 12:34 PM
To: [hidden email]
Subject: Re: [Enthought-Dev] Traits & MenuBar

Hello,

I changed my code and tried this:

_my_action = Instance(Action)
_tool_bar = Instance(toolBar)


view = View(
        Item('myitem'),
        ...
      toolbar = '_tool_bar'
)

def __my_action_default(self):
    Return Action (name = 'MyAction',
                   on_perform = self.do_action,
                   enabled = True)

def __tool_bar_default(self):
    m = ToolBar(
                self._my_action,
                show_tool_names = False
            )
    return m


But the toolbar doesn't appear...
Any idea?

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Boiteux, Benoit
Sent: Friday, February 12, 2010 3:19 PM
To: [hidden email]
Subject: [Enthought-Dev] Traits & MenuBar

Hello,

I created a view where I'd like to add a menubar.
I tried to use Traits User manual, but this one seems out of date since Action class doesn't contain any 'action' attribute anymore.

My view is like:
View(
        Item('myitem'),
        ...
      menubar = MenuBar(
                                Menu('exit_action', name='&File'),
                               
                                )
)

And I defined exit_action in the constructor of the HasTraits class:
 
self.exit_action = Action(name='E&xit', on_perform=self.close)

but Exit item doesn't appear.

What is the rule to create toolbar and menubar in a view ?

Thanks
Benoit
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

Re: Traits & MenuBar

bryce hendrix-2
Benoit,

Which Action are you instantiating? Traits and Pyface both have an
Action class. Use the one from enthought.pyface.action.api

Bryce

Boiteux, Benoit wrote:

> Hi again,
>
> Traits and Menubar/Toolbar starts making me crazy :)
>
> I have the following code (part of a HasTraits)
>     class MyHandler(Handler):
>         def do_record_action(self,UIInfo):
>             return
>        
>         record_action = Action(name = "Record",action = 'do_record_action')
>    
>     view = View(
>                 HSplit(
>                        Item('proj', show_label = False, editor=InstanceEditor(view='chan_conf_view'), style='custom'),
>                        Item('plot', show_label = False, editor=ComponentEditor()),
>                        Item('proj', show_label = False, editor=InstanceEditor(view='chan_meas_view'), style='custom'),
>                        ),
>                 toolbar = ToolBar(record_action),
>                 menubar = MenuBar(Menu(record_action,name="Record")),
>                 icon = ImageResource('../PowerAnalyzer.ico'),
>                 title="Power Analyzer v0.5",
>                 resizable = True,
>                 width = 1280,
>                 height = 900,
>                 handler = MyHandler()              
>                 )
>
> If I use wx backend, menubar and toolbar appear correctly
> If I use qt backend, toolbar doesn't appear at all and menubar has "Record" with a blank menu item...
> Is it a bug or I did something wrong ?
>
> Then, with wx backup, If I click on the toolbar, I have:
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\pyface\ui\wx\action\action_item.py", line 473, in _on_tool
>     self.controller.perform(action)
>   File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\traits\ui\wx\ui_base.py", line 282, in perform
>     self.ui.do_undoable( self._perform, action )
>   File "C:\Python26\lib\site-packages\traits-3.2.0-py2.6-win32.egg\enthought\traits\ui\ui.py", line 704, in do_undoable
>     action( *args, **kw )
>   File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\traits\ui\wx\ui_base.py", line 298, in _perform
>     action.perform()
> TypeError: perform() takes exactly 2 arguments (1 given)
>
> Any idea ?
>
> Thanks
> benoit
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Boiteux, Benoit
> Sent: Monday, February 15, 2010 12:34 PM
> To: [hidden email]
> Subject: Re: [Enthought-Dev] Traits & MenuBar
>
> Hello,
>
> I changed my code and tried this:
>
> _my_action = Instance(Action)
> _tool_bar = Instance(toolBar)
>
>
> view = View(
> Item('myitem'),
> ...
>       toolbar = '_tool_bar'
> )
>
> def __my_action_default(self):
>     Return Action (name = 'MyAction',
>                    on_perform = self.do_action,
>                    enabled = True)
>
> def __tool_bar_default(self):
>     m = ToolBar(
>                 self._my_action,
>                 show_tool_names = False
>             )
>     return m
>
>
> But the toolbar doesn't appear...
> Any idea?
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Boiteux, Benoit
> Sent: Friday, February 12, 2010 3:19 PM
> To: [hidden email]
> Subject: [Enthought-Dev] Traits & MenuBar
>
> Hello,
>
> I created a view where I'd like to add a menubar.
> I tried to use Traits User manual, but this one seems out of date since Action class doesn't contain any 'action' attribute anymore.
>
> My view is like:
> View(
> Item('myitem'),
> ...
>       menubar = MenuBar(
> Menu('exit_action', name='&File'),
>
> )
> )
>
> And I defined exit_action in the constructor of the HasTraits class:
>  
> self.exit_action = Action(name='E&xit', on_perform=self.close)
>
> but Exit item doesn't appear.
>
> What is the rule to create toolbar and menubar in a view ?
>
> Thanks
> Benoit
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris,
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris,
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris,
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> _______________________________________________
> 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 & MenuBar

Boiteux, Benoit
Hello Bryce,
I used enthought.traits.ui.menu Action
I followed the Traits UI UG.

If I use pyface Action, The way to create Action is different.
That means I don't have to use handler anymore ?
How do I declare the Action ?

I tried to maintain the view handler, but I have the following error:
AttributeError: 'Action' object has no attribute 'defined_when'

Benoit

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of bryce hendrix
Sent: Wednesday, February 17, 2010 6:14 PM
To: [hidden email]
Subject: Re: [Enthought-Dev] Traits & MenuBar

Benoit,

Which Action are you instantiating? Traits and Pyface both have an
Action class. Use the one from enthought.pyface.action.api

Bryce

Boiteux, Benoit wrote:

> Hi again,
>
> Traits and Menubar/Toolbar starts making me crazy :)
>
> I have the following code (part of a HasTraits)
>     class MyHandler(Handler):
>         def do_record_action(self,UIInfo):
>             return
>        
>         record_action = Action(name = "Record",action = 'do_record_action')
>    
>     view = View(
>                 HSplit(
>                        Item('proj', show_label = False, editor=InstanceEditor(view='chan_conf_view'), style='custom'),
>                        Item('plot', show_label = False, editor=ComponentEditor()),
>                        Item('proj', show_label = False, editor=InstanceEditor(view='chan_meas_view'), style='custom'),
>                        ),
>                 toolbar = ToolBar(record_action),
>                 menubar = MenuBar(Menu(record_action,name="Record")),
>                 icon = ImageResource('../PowerAnalyzer.ico'),
>                 title="Power Analyzer v0.5",
>                 resizable = True,
>                 width = 1280,
>                 height = 900,
>                 handler = MyHandler()              
>                 )
>
> If I use wx backend, menubar and toolbar appear correctly
> If I use qt backend, toolbar doesn't appear at all and menubar has "Record" with a blank menu item...
> Is it a bug or I did something wrong ?
>
> Then, with wx backup, If I click on the toolbar, I have:
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\pyface\ui\wx\action\action_item.py", line 473, in _on_tool
>     self.controller.perform(action)
>   File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\traits\ui\wx\ui_base.py", line 282, in perform
>     self.ui.do_undoable( self._perform, action )
>   File "C:\Python26\lib\site-packages\traits-3.2.0-py2.6-win32.egg\enthought\traits\ui\ui.py", line 704, in do_undoable
>     action( *args, **kw )
>   File "C:\Python26\lib\site-packages\traitsbackendwx-3.2.0-py2.6.egg\enthought\traits\ui\wx\ui_base.py", line 298, in _perform
>     action.perform()
> TypeError: perform() takes exactly 2 arguments (1 given)
>
> Any idea ?
>
> Thanks
> benoit
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Boiteux, Benoit
> Sent: Monday, February 15, 2010 12:34 PM
> To: [hidden email]
> Subject: Re: [Enthought-Dev] Traits & MenuBar
>
> Hello,
>
> I changed my code and tried this:
>
> _my_action = Instance(Action)
> _tool_bar = Instance(toolBar)
>
>
> view = View(
> Item('myitem'),
> ...
>       toolbar = '_tool_bar'
> )
>
> def __my_action_default(self):
>     Return Action (name = 'MyAction',
>                    on_perform = self.do_action,
>                    enabled = True)
>
> def __tool_bar_default(self):
>     m = ToolBar(
>                 self._my_action,
>                 show_tool_names = False
>             )
>     return m
>
>
> But the toolbar doesn't appear...
> Any idea?
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Boiteux, Benoit
> Sent: Friday, February 12, 2010 3:19 PM
> To: [hidden email]
> Subject: [Enthought-Dev] Traits & MenuBar
>
> Hello,
>
> I created a view where I'd like to add a menubar.
> I tried to use Traits User manual, but this one seems out of date since Action class doesn't contain any 'action' attribute anymore.
>
> My view is like:
> View(
> Item('myitem'),
> ...
>       menubar = MenuBar(
> Menu('exit_action', name='&File'),
>
> )
> )
>
> And I defined exit_action in the constructor of the HasTraits class:
>  
> self.exit_action = Action(name='E&xit', on_perform=self.close)
>
> but Exit item doesn't appear.
>
> What is the rule to create toolbar and menubar in a view ?
>
> Thanks
> Benoit
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris,
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris,
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris,
> 92196 Meudon Cedex, France
> Registration Number:  302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> _______________________________________________
> 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
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

Re: Traits & MenuBar

bryce hendrix-2
Boiteux, Benoit wrote:
> Hello Bryce,
> I used enthought.traits.ui.menu Action
> I followed the Traits UI UG.
>
> If I use pyface Action, The way to create Action is different.
> That means I don't have to use handler anymore ?
> How do I declare the Action ?
>  

Ugh, sorry I looked at the wrong code when I was checking which Action
class to use. Here is a complete example, which works with Wx and Qt4
for me.:


from enthought.pyface.action.api import Group as ActionGroup
from enthought.traits.api import HasTraits, Int
from enthought.traits.ui.api import Handler, View, Item
from enthought.traits.ui.menu import Action, Menu, MenuBar

class MyHandler(Handler):
    def increment(self, info):
        my_view = info.ui.context['object']
        my_view.value += 1

class MyView(HasTraits):
    value = Int(0)

    def trait_view(self, parent=None):
        my_menu_group = ActionGroup(Action(name='Increment Value',
                                           action='increment'))
        menu = Menu(my_menu_group, name='my actions')
        menu_bar = MenuBar(menu)

        return View(Item('value'),
                    handler=MyHandler(),
                    menubar=menu_bar)

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

Re: Traits & MenuBar

Boiteux, Benoit
Thanks a lot Bryce, that works well !
Shame on me, I didn't think I could use 'trait_view' to declare the actions..

I did the same kind of code to create the toolbar:

class ViewHandler(Handler):
        ...
        def do_playback_action(self,UIInfo):
            my_view = UIInfo.ui.context['object']
            my_view.replay_log()

def trait_view(self, parent=None):
        ...
        playback_action = Action (name = 'Playback',
                                   action = 'do_playback_action',
                                   image = ImageResource('playback'),
                                   enabled = True,
                                   tooltip = "Replay acquisition log file")

        return View(
                    HSplit(
                           Item('proj', show_label = False, editor=InstanceEditor(view='chan_conf_view'), style='custom'),
                           Item('plot', show_label = False,editor=ComponentEditor()),
                           Item('proj', show_label = False,editor=InstanceEditor(view='chan_meas_view'), style='custom'),
                           ),
                    toolbar = ToolBar(playback_action),
                          ....

I don't have any error, but the toolbar doesn't appear (qt backend)
If I change the backend to 'wx', the toolbar appears, and the control works perfectly.

Toolbar doesn't like Qt ? :)

benoit
                       

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of bryce hendrix
Sent: Thursday, February 18, 2010 5:47 PM
To: [hidden email]
Subject: Re: [Enthought-Dev] Traits & MenuBar

Boiteux, Benoit wrote:
> Hello Bryce,
> I used enthought.traits.ui.menu Action
> I followed the Traits UI UG.
>
> If I use pyface Action, The way to create Action is different.
> That means I don't have to use handler anymore ?
> How do I declare the Action ?
>  

Ugh, sorry I looked at the wrong code when I was checking which Action
class to use. Here is a complete example, which works with Wx and Qt4
for me.:


from enthought.pyface.action.api import Group as ActionGroup
from enthought.traits.api import HasTraits, Int
from enthought.traits.ui.api import Handler, View, Item
from enthought.traits.ui.menu import Action, Menu, MenuBar

class MyHandler(Handler):
    def increment(self, info):
        my_view = info.ui.context['object']
        my_view.value += 1

class MyView(HasTraits):
    value = Int(0)

    def trait_view(self, parent=None):
        my_menu_group = ActionGroup(Action(name='Increment Value',
                                           action='increment'))
        menu = Menu(my_menu_group, name='my actions')
        menu_bar = MenuBar(menu)

        return View(Item('value'),
                    handler=MyHandler(),
                    menubar=menu_bar)

MyView().configure_traits()
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

Re: Traits & MenuBar

bryce hendrix-2
On 2/19/2010 2:12 AM, Boiteux, Benoit wrote:
> Thanks a lot Bryce, that works well !
> Shame on me, I didn't think I could use 'trait_view' to declare the actions..
>    

You don't have to declare it in the traits_view method, you could use
global instances as well, but I prefer to keep it all localized if its
not being re-used

> I did the same kind of code to create the toolbar:
>
> ...
> I don't have any error, but the toolbar doesn't appear (qt backend)
> If I change the backend to 'wx', the toolbar appears, and the control works perfectly.
>
> Toolbar doesn't like Qt ? :)
>
>    

I don't know if the ToolBar has been completely implemented in Qt or
not. As I've said before, I lean towards using SVGButton instances
inside a HGroup instead. With the Qt4 backend, the SVGButtonEditor uses
the Qt4 SVG renderer, which is very nice. On the Wx backend it uses the
savage wx renderer, which is still good as long as you don't go crazy
with multi-stop gradients and filters.

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 & MenuBar

Boiteux, Benoit
Ok, I'm gonna have a try with SVGButtonEditor !

Thanks for your support,
Benoit

-----Original Message-----
From: Bryce Hendrix [mailto:[hidden email]]
Sent: Friday, February 19, 2010 4:57 PM
To: [hidden email]
Cc: Boiteux, Benoit
Subject: Re: [Enthought-Dev] Traits & MenuBar

On 2/19/2010 2:12 AM, Boiteux, Benoit wrote:
> Thanks a lot Bryce, that works well !
> Shame on me, I didn't think I could use 'trait_view' to declare the actions..
>    

You don't have to declare it in the traits_view method, you could use
global instances as well, but I prefer to keep it all localized if its
not being re-used

> I did the same kind of code to create the toolbar:
>
> ...
> I don't have any error, but the toolbar doesn't appear (qt backend)
> If I change the backend to 'wx', the toolbar appears, and the control works perfectly.
>
> Toolbar doesn't like Qt ? :)
>
>    

I don't know if the ToolBar has been completely implemented in Qt or
not. As I've said before, I lean towards using SVGButton instances
inside a HGroup instead. With the Qt4 backend, the SVGButtonEditor uses
the Qt4 SVG renderer, which is very nice. On the Wx backend it uses the
savage wx renderer, which is still good as long as you don't go crazy
with multi-stop gradients and filters.

Bryce

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

Re: ipython/ipdb & traits question

_jelle_
In reply to this post by Robert Kern
>You can change this like so:
>   from enthought.traits.api import push_exception_handler
>   push_exception_handler(reraise_exceptions=True)

I forgot to confirm that this indeed resolves the issue.
Mr Kern you are an expert, thanks!






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