{"action":"created","issue":{"url":"https://api.github.com/repos/enthought/traitsui/issues/324","repository_url":"https://api.github.com/repos/enthought/traitsui","labels_url":"https://api.github.com/repos/enthought/traitsui/issues/324/labels{/name}","comments_url":"https://api.github.com/repos/enthought/traitsui/issues/324/comments","events_url":"https://api.github.com/repos/enthought/traitsui/issues/324/events","html_url":"https://github.com/enthought/traitsui/issues/324","id":195657662,"number":324,"title":"traitsui/view.py:View.ui incompatible with has_traits","user":{"login":"spichardo","id":2280143,"avatar_url":"https://avatars.githubusercontent.com/u/2280143?v=3","gravatar_id":"","url":"https://api.github.com/users/spichardo","html_url":"https://github.com/spichardo","followers_url":"https://api.github.com/users/spichardo/followers","following_url":"https://api.github.com/users/spichardo/following{/other_user}","gists_url":"https://api.github.com/users/spichardo/gists{/gist_id}","starred_url":"https://api.github.com/users/spichardo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spichardo/subscriptions","organizations_url":"https://api.github.com/users/spichardo/orgs","repos_url":"https://api.github.com/users/spichardo/repos","events_url":"https://api.github.com/users/spichardo/events{/privacy}","received_events_url":"https://api.github.com/users/spichardo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-14T21:59:13Z","updated_at":"2016-12-15T07:26:25Z","closed_at":null,"body":"Hi,\r\n\r\nIn their current versions of [traitsui](https://github.com/enthought/traitsui/commit/c8ae6702c7074ee84b9df064e62b7a409f0155f8) and [traits](https://github.com/enthought/traits/commit/6613b0fb4fe465d4f78d1abe067ec92a22c2f8f9), the `View.ui` function is calling the old-fashion function to set properties of `has_traits`:\r\n```python\r\n    def ui(self, context, parent=None, kind=None,\r\n            view_elements=None, handler=None,\r\n            id='', scrollable=None,\r\n            args=None):\r\n...\r\n        if args is not None:\r\n            handler.set(**args)\r\n...\r\n```\r\n\r\n`has_traits` complains that this method is now deprecated:\r\n\r\n> ... Uncaught exception\r\n> Traceback (most recent call last):\r\n>   File \"C:\\Anaconda2\\envs\\py33\\lib\\runpy.py\", line 160, in _run_module_as_main\r\n>     \"__main__\", fname, loader, pkg_name)\r\n>   File \"C:\\Anaconda2\\envs\\py33\\lib\\runpy.py\", line 73, in _run_code\r\n>     exec(code, run_globals)\r\n>   File \"E:\\Github\\HyperthermiaHeadAndNeck\\MAIN_APP.py\", line 1072, in <module>\r\n>     main()\r\n>   File \"E:\\Github\\HyperthermiaHeadAndNeck\\MAIN_APP.py\", line 1068, in main\r\n>     ex = HyperthermiaNeckApp(InitDir=InitDir,InitFile=InitFile)\r\n>   File \"E:\\Github\\HyperthermiaHeadAndNeck\\MAIN_APP.py\", line 187, in __init__\r\n>     self.__initUI()\r\n>   File \"E:\\Github\\HyperthermiaHeadAndNeck\\MAIN_APP.py\", line 257, in __initUI\r\n>     self.MainContainer=WidgetSlices(parent=self,DataDirectory=self.DataDirectory)\r\n>   File \".\\WidgetSlices.py\", line 45, in __init__\r\n>     self.slice_wdt[SelKey]=self.slice[SelKey].edit_traits(parent=self).control\r\n>   File \"E:\\Github\\Proteus\\GUI\\MRIInspection.py\", line 121, in edit_traits\r\n>     retVal = super(ShowSlice,self).edit_traits(parent=parent)\r\n>   File \"C:\\Anaconda2\\envs\\py33\\lib\\site-packages\\traits-4.7.0.dev2-py3.3-win-amd64.egg\\traits\\has_traits.py\", line 1871, in edit_traits\r\n>     handler, id, scrollable, args )\r\n>   File \"C:\\Anaconda2\\envs\\py33\\lib\\site-packages\\traitsui-5.2.0.dev55-py3.3.egg\\traitsui\\view.py\", line 423, in ui\r\n>     handler.set(**args)\r\n>   File \"C:\\Anaconda2\\envs\\py33\\lib\\site-packages\\traits-4.7.0.dev2-py3.3-win-amd64.egg\\traits\\util\\deprecated.py\", line 31, in wrapper\r\n>     warnings.warn(message, DeprecationWarning, stacklevel=2)\r\n> DeprecationWarning: use \"HasTraits.trait_set\" instead\r\n\r\nFor the moment to make it work I'm disabling in `has_traits` the `@deprecate` decorator:\r\n```python\r\n    # Defines the deprecated alias for 'trait_set'\r\n    #@deprecated('use \"HasTraits.trait_set\" instead')\r\n    def set ( self, trait_change_notify = True, **traits ):\r\n        return self.trait_set(\r\n            trait_change_notify=trait_change_notify, **traits)\r\n```\r\n\r\nAny ideas how in the `ui` function the properties should be set now using the new`has_traits` convention?\r\n"},"comment":{"url":"https://api.github.com/repos/enthought/traitsui/issues/comments/267257641","html_url":"https://github.com/enthought/traitsui/issues/324#issuecomment-267257641","issue_url":"https://api.github.com/repos/enthought/traitsui/issues/324","id":267257641,"user":{"login":"corranwebster","id":600761,"avatar_url":"https://avatars.githubusercontent.com/u/600761?v=3","gravatar_id":"","url":"https://api.github.com/users/corranwebster","html_url":"https://github.com/corranwebster","followers_url":"https://api.github.com/users/corranwebster/followers","following_url":"https://api.github.com/users/corranwebster/following{/other_user}","gists_url":"https://api.github.com/users/corranwebster/gists{/gist_id}","starred_url":"https://api.github.com/users/corranwebster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corranwebster/subscriptions","organizations_url":"https://api.github.com/users/corranwebster/orgs","repos_url":"https://api.github.com/users/corranwebster/repos","events_url":"https://api.github.com/users/corranwebster/events{/privacy}","received_events_url":"https://api.github.com/users/corranwebster/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T07:26:25Z","updated_at":"2016-12-15T07:26:25Z","body":"The fix is to replace all uses of `set` with `trait_set` in TraitsUI and all other upstream packages.\r\n\r\nHowever, this is a deprecation warning - functionality is not affected - so the simplest workaround is to turn off deprecation warnings using the warnings module."}}
{"actor":{"display_login":"corranwebster"}}