traitsui

How do I update the dictionary of a mapped trait, after I've already constructed it?

ぐ巨炮叔叔 提交于 2020-01-24 01:08:25
问题 I need to update the dictionary of a mapped trait some time after initial trait creation. How do I do this? The following code: from traits.api import (HasTraits, Trait) class bar(HasTraits): zap = Trait("None", {"None": None}) def __init__(self): # In reality, determined programmatically at runtime. add_dict_entries = {"One": 1} new_dict = {"None": None} new_dict.update(add_dict_entries) self.zap = Trait("None", new_dict) theBar = bar() yields: Traceback (most recent call last): File "tst

listen for ctf otf changes with traits in mayavi volume rendering

回眸只為那壹抹淺笑 提交于 2019-12-24 16:15:09
问题 I would like to listen to changes in the transfer function in how the color and opacity (ctf/otf) of my data is represented. Listening to sensible-sounding traits such as mayavi.modules.volume.Volume._ctf does not trigger my callback. I would expect this to be changed by the user either through the "standard" mayavi pipeline display (as part of EngineRichView) or through including the Volume object's view directly. No such luck either way. It is maybe telling that when you press the big red

Freezing (.exe) a traitsUI program, realistically feasible?

蹲街弑〆低调 提交于 2019-12-13 14:01:16
问题 I'm trying to freeze with either cx_freeze or pyInstaller a TraitsUI program that makes use of Chaco, Traits, TraitsUI and to a lesser extent mayavi (could actually be taken out). I need this to run on mac, linux, ubuntu so am avoiding py2exe. I've intentionally uninstalled pyqt and pyside so that only the wx backend is available. Using cx_freeze, I encountered and reported a bug, so pyInstaller seems to be getting me the furthest. It generated an .exe file, but when I run the file I get

Sphinx autodoc incorrectly assigning value 'None' to class attributes, when Traits are used

强颜欢笑 提交于 2019-12-13 01:06:18
问题 I'm seeing Python class attributes incorrectly assigned the value, None , in Sphinx autodoc generated documentation, when Traits are used. I have a simple test case with instructions for observing the error, here: https://github.com/capn-freako/SphinxTest It shows that: When object is used as the superclass, and int is the class attribute's type, the generated documentation is as expected. When HasTraits is used as the superclass and Int is the class attribute's type, the generated

How do I make an edit_traits() GUI item responsive to changes in its dependencies?

醉酒当歌 提交于 2019-12-12 10:18:51
问题 I'm designing a HasTraits subclass with dependent properties: #!/usr/bin/env python # Example for SO question on dynamically changing Dict contents. from traits.api import HasTraits, Dict, Property, Trait, Int, cached_property from traitsui.api import View, Item class Foo(HasTraits): "Has dependent properties, which I'd like to remain up-to-date in the GUI." _dicts = [ {"zero": 0, "one": 1}, {"zero": 1, "one": 2}, {"zero": 2, "one": 3}, ] zap = Int(0) bar = Property(Trait, depends_on=["zap"])

Defining view elements from dictionary elements in TraitsUI

試著忘記壹切 提交于 2019-12-11 23:33:04
问题 Is there a way to reference items in a dictionary in traitsui views? In other words, is there a way to do what I mean with the following, using a Dict trait: from traits.api import * from traitsui.api import * from traitsui.ui_editors.array_view_editor import ArrayViewEditor import numpy as np class SmallPartOfLargeApplication(HasTraits): a=Dict def _a_default(self): return {'a_stat':np.random.random((10,1)), 'b_stat':np.random.random((10,10))} traits_view=View( Item('a.a_stat',editor

Python TraitsUI - how to control scrollbar position of a 'String' trait editor/view

泪湿孤枕 提交于 2019-12-11 07:22:17
问题 I'm using Traits 4 to build a simple interactive GUI application. This application will display a timestamped log of events in a dedicated part of the GUI. This log is currently stored as a String trait. The default editor (or View? Not sure on the exact nomenclature) for a String trait is a scrollable multi-line display widget. When the internal string value is changed, the widget updates to display the new value. If the length of the content exceeds the viewable size of the widget, then a

Change mlab quiver3d & surf data sources without clearing figure in traits script

久未见 提交于 2019-12-11 05:28:14
问题 I have a Traits and Mayavi script that presents an mlab scene and several traits editors. The editors affect what data is shown in a surface , quiver3d and legend (Scalar LUT Manager) by calling my drawing method. Each change triggers a clear figure and re-draw. Learning from the Mlab interactive dialog example the plot3d * uses mlab_source.set to change the data without clearing the figure and re-drawing. In update_plot(): if self.plot is None: self.plot = self.scene.mlab.plot3d(x, y, z, t,

Column widths with TabularAdapters?

牧云@^-^@ 提交于 2019-12-11 03:19:19
问题 Using Enthought Canopy's TraitsUI, I'm using TabularAdapters to display some Arrays, but they always produce evenly proportioned column widths...I'd like to make some widths smaller than others, but haven't found any simple way yet...Anyone have any suggestions? 回答1: One way to control the widths of the columns is to override the get_width() method of the TabularArrayAdapter . For example, import numpy as np from traits.api import HasTraits, Array from traitsui.api import View, Item,

adding nested HasTraits properties to a TraitsUI TView

天涯浪子 提交于 2019-12-10 11:42:18
问题 i have a main HasTraits class which contains several Instance's of other HasTraits objects. I would like to define an Item in the view of the main object which points to a trait of a nested object. for example: class Person(HasTraits): name = String() class Pet(HasTraits): name = String() class Family(HasTraits): father = Instance(Person,()) dog = Instance(Pet,()) view = View( Item('father.name'), Item('dog.name'), ) is this possible? thanks! 回答1: Somebody named Alex asked this question 1