0

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!

user2175850
  • 193
  • 2
  • 13
  • I am not able to reproduce this problem. what versions of traitsui and pyqt are you running and what pyqt implementation (pyqt4 or pyside)? – aestrivex Jun 17 '15 at 21:58
  • Hi, thanks for your help. Here are some version details below: Python 2.7.3 traits 4.1.0 traitsui 4.1.0 PyQt4 installed. No PySide installed. please let me know if there is more information you need. – user2175850 Jun 18 '15 at 11:23

1 Answers1

0

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

user2175850
  • 193
  • 2
  • 13