All Questions
118 questions
0
votes
0
answers
14
views
How to catch leaflet event and send it to a Traits app?
I have a Python Traits app which consists in a instance of the HTML class (to say short).
In this instance, I have a leaflet map.
That works fine (it displays a leaflet map).
I know how to catch ...
0
votes
1
answer
51
views
Handle nested traits changes with traits api
I am having some issues building a GUI with traits and traitsui.
What I am trying to do can be simplified to the following:
from traits.api import List, Str, on_trait_change, Trait, HasTraits
from ...
0
votes
2
answers
301
views
Python mixins : how to deal with *args, **kwargs when calling super()?
In the following example I show some mixins that may or may not use *args or **kwargs:
class AMixin():
def __init__(self, **kwargs):
print("AMixin")
self.a = 'a' + str(...
1
vote
2
answers
610
views
How to specify variable-length tuple of specific type in traits?
from traits.api import HasTraits, Str, Tuple
class Data(HasTraits):
values = Tuple(Str, ...)
data = Data(values=("a", "b", "c"))
Output:
TraitError: The '...
0
votes
1
answer
65
views
Adding methods (roles) to a class on the fly in Python - dangers?
I'm learning python, and having fun with classes. Since I'm used to roles or traits in other contexts and found them extremely useful, I was looking into the same kind of thing - adding a class to ...
2
votes
2
answers
694
views
Set ipywidget options with nothing selected
When I want to set options in an ipywidget with nothing selected I would simply do this:
import ipywidgets as w
w.Select(options=[1, 2], value=None)
What if I wanted to set new items (with nothing ...
2
votes
0
answers
469
views
Change pointer cursor in jupyter over ipywidgets
I've been searching and I can't find a way to change the cursor in a jupyter notebook. I'm working with my own designed file chooser using ipywidgets and I want to change the cursor image every time ...
2
votes
1
answer
902
views
PyO3 - passing class extending another class as a function argument
I have a library in Rust and I want to be able to use it from Python. So I can do the bindings using PyO3.
Let's suppose that I have a following library in Rust:
pub trait Animal {
fn make_sound();...
-1
votes
1
answer
653
views
how could i use @ character as a Rust decorator to implement trait to a struct?
How could i use decorator with if possible @ character to have python style taste while implementing traits on my structs ?
trait Animal {
fn get_name(&self) -> &str {
&...
0
votes
3
answers
185
views
How do I update the dictionary of a mapped trait, after I've already constructed it?
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):
...
1
vote
0
answers
377
views
Traitlets: Best way for a "Dict of Instance"?
In my code, I need a Dict of Instance (for example a list of Parameter keyed by name). Currently I've solved this by using a regular Dict-traitlet as the incoming property (parameters) and then having ...
4
votes
0
answers
1k
views
Converting GUI-application into .exe-file with cx_Freeze: no plugin found for toolkit qt4
My program contains mayavi, traits and pyqt5 elements in order to visualize something in 3D.
I tried to convert my GUI-Application with cx_Freeze and it created the exe-file ,but running it I got the ...
1
vote
1
answer
71
views
Initialisation of traits.Tuple value in a traits.Tuple object
>>> import traits.api as traits
>>> class Foo(traits.HasTraits):
... eTest = traits.Tuple((0.0001, 60, traits.Tuple(traits.Bool(False), traits.Bool(True))))
...
>>> a=Foo()...
0
votes
0
answers
71
views
"Do not create a new QApplication" when embedding mayavi in QT?
In the official example of "embedding mayavi in QT"
http://docs.enthought.com/mayavi/mayavi/auto/example_qt_embedding.html#example-qt-embedding,
the main code says:
if __name__ == "__main__":
# ...
3
votes
1
answer
189
views
How to enable right-click menu in TraitsUI TreeView when using adaptors?
I have modified the Adapted_tree_editor_demo.py example code to display some simple model objects using the adaptor approach. However, right-click menu options are all disabled. How can I enable them? ...