Traitsui Qt4 Menu actions give error in linux (works on windows)

71 views Asked by At

I am trying to get a traitsui/Chaco application to work on linux. It is stable and working fine on Windows. I noticed that when I run my application on linux (I am using Raspbian wheezy ) I get the below error whenever I click on a menu item that calling a Action:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pyface/ui/qt4/action/action_item.py", line 160, in _qt4_on_triggered
    self.controller.perform(action)
  File "/usr/lib/python2.7/dist-packages/traitsui/qt4/ui_base.py", line 135, in perform
    self.ui.do_undoable( self._perform, action )
  File "/usr/lib/python2.7/dist-packages/traitsui/ui.py", line 710, in do_undoable
    action( *args, **kw )
  File "/usr/lib/python2.7/dist-packages/traitsui/qt4/ui_base.py", line 142, in _perform
    action.perform()
TypeError: perform() takes exactly 2 arguments (1 given)

Below is a minimal example that creates the problem. The Menu works fine and correctly on Windows but when I run it on linux I get the above error, whenever I click a Menu Item.

try:
    from traits.etsconfig.api import ETSConfig
    ETSConfig.toolkit = 'qt4'
except ValueError as e:
    print "Error loading QT4"
    print "error was: "+ str(e.message)
    pass

import traitsui.api as traitsui
import traits.api as traits


class Simple(traits.HasTraits):

    f = traits.Float(1.0)
    menubar = traitsui.MenuBar(
            traitsui.Menu(
                traitsui.Action(name='test Action', action='_run_action'), name="Menu")
            )

    traits_view = traitsui.View(
                        traitsui.Item("f"), menubar=menubar)

    def _run_action(self):
        self.f*=-1.0

    def _run_action_2(self):
        self.f*=-2.0



if __name__=="__main__":
    s = Simple()
    s.configure_traits()

I noticed there is some comment about this in tes_actions.py file( Line 113)

https://github.com/enthought/traitsui/blob/master/traitsui/tests/test_actions.py

but I don't understand what it means. Does anyone know how to get around this? I assume there must be a way to get the Menu Actions working in Linux.

Thanks!

1

There are 1 answers

0
user2175850 On

I managed to fix this after I saw in the Git history that the fix was committed in version 4.2.0.

When I did sudo apt-get install traitsui it installed version 4.1.0.

I pulled the latest repository from git and reinstalled (for traitsui and traits) and the problem was fixed.

Thanks,

Tim