全部版块 我的主页
论坛 站务区 十一区 新手入门区
786 1
2022-04-14

from traits.api import HasTraits, Str, Range, Enum

class Person(HasTraits):

name = Str('Jane Doe')

age = Range(low=0)

gender = Enum('female', 'male')

person = Person(age=30)

from traitsui.api import Item, RangeEditor, View

person_view = View(

Item('name'),

Item('gender'),

Item('age', editor=RangeEditor(mode='spinner', low=0, high=150)),

buttons=['OK', 'Cancel'],

resizable=True,

)

person.configure_traits(view=person_view)


Traceback (most recent call last):

File "F:\pythonProject1\lib\site-packages\IPython\core\interactiveshell.py", line 3369, in run_code

exec(code_obj, self.user_global_ns, self.user_ns)

File "<ipython-input-7-2991deb889ce>", line 11, in <cell line: 11>

person.configure_traits(view=person_view)

File "F:\pythonProject1\lib\site-packages\traits\has_traits.py", line 2174, in configure_traits

rc = toolkit().view_application(

File "F:\pythonProject1\lib\site-packages\traitsui\toolkit.py", line 238, in view_application

raise NotImplementedError(

NotImplementedError: the 'null' toolkit does not implement this method


这个问题该怎么解决呢?


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2022-4-16 00:12:07
person.configure_traits()
这个里面可以传参数吗?
(同初学)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群