You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'll start with that I really like vispy! I wonder if the following would be worth a pull request.
Using vispy 0.5.0.dev0, I was trying to update dynamically the colorbar label from ColorBarWidget.
(1) To set the label from the colorbar widget (ColorBarWidget), I need to pass the label_str directly as the 'label' parameter isn't linked to anything. This works well. This means that the call to ColorBarVisual in ColorBarWidget could be changed to
(2) To update it I tried two things. First, I try to simply recreate (self.grid.remove_widget followed by self.grid.add_widget) the whole widget and add it back to the grid. E.g.
It works fine for clim and cmap with no change. However, the setter for label directly calls ColorBarVisual @label.setter which should not accept text directly as in init, it is set via label_str as follow:
Adding a setter for label_str can be used to then update it via the label setter. So that in ColorBarWidget, the setter for label would be modifying self.label_str. This work fine. E.g.
# In ColorBarWidget
@label.setter
def label(self, label):
self._colorbar.label_str = label
# In ColorBarVisual
@property
def label(self):
""" The vispy.visuals.TextVisual associated with the label
"""
return self._label
@label.setter
def label(self, label):
self._label = label
self._update()
@property
def label_str(self):
return self._label_str
@label_str.setter
def label_str(self, label_str):
self._label_str = label_str
self._update()
As a side note, I also added the following to ColorBarWidget so that I can modify the color and size of the ticks. I guess this could be added to the lot.
Have the same problem in my application. In #1271 I tried to get all needed functionality within ColorBarWidget and ColorBarVisual without changing the calling conventions (just adding to them).
Hi,
I'll start with that I really like vispy! I wonder if the following would be worth a pull request.
Using vispy 0.5.0.dev0, I was trying to update dynamically the colorbar label from ColorBarWidget.
(1) To set the label from the colorbar widget (ColorBarWidget), I need to pass the label_str directly as the 'label' parameter isn't linked to anything. This works well. This means that the call to ColorBarVisual in ColorBarWidget could be changed to
(2) To update it I tried two things. First, I try to simply recreate (self.grid.remove_widget followed by self.grid.add_widget) the whole widget and add it back to the grid. E.g.
Somehow, it doesn't refresh and I end up with the previous text being drawn underneath the new text -- which makes everything unreadable.
The second thing I tried is keep track of cbar and simply update its parameters. E.g.
It works fine for clim and cmap with no change. However, the setter for label directly calls ColorBarVisual @label.setter which should not accept text directly as in init, it is set via label_str as follow:
Adding a setter for label_str can be used to then update it via the label setter. So that in ColorBarWidget, the setter for label would be modifying self.label_str. This work fine. E.g.
As a side note, I also added the following to ColorBarWidget so that I can modify the color and size of the ticks. I guess this could be added to the lot.
The text was updated successfully, but these errors were encountered: