Skip to content

Conversation

bmorris3
Copy link
Contributor

Description

In the custom viewer docs, there's a reference to a variable that's never defined. It looks like a holdover/typo. I revised the line with my best-guess at what I think belongs there, correct me if I'm wrong.

Copy link
Member

@Carifio24 Carifio24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like TutorialViewerState was previously MyExampleState and this line didn't get updated when renaming. We need to access linestyle through the class in order to set the choices - self.linestyle will just return the current linestyle value, but TutorialViewerState.linestyle will give us the SelectionCallbackProperty object.

@@ -149,7 +149,7 @@ which should be used as follows::

def __init__(self, *args, **kwargs):
super(TutorialViewerState).__init__(*args, **kwargs)
MyExampleState.linestyle.set_choices(['solid', 'dashed', 'dotted'])
self.linestyle.set_choices(['solid', 'dashed', 'dotted'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.linestyle.set_choices(['solid', 'dashed', 'dotted'])
TutorialViewerState.linestyle.set_choices(['solid', 'dashed', 'dotted'])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the proposed fix fails for me because self.linestyle is a just initialised SelectionCallbackProperty() here.
The equivalent in existing classes seems to be
https://github.com/glue-viz/glue/blob/f933d4bb69395c986ef1e2b3ec6ef0e64d422aea/glue/viewers/scatter/state.py#L319

Copy link
Contributor

@dhomeier dhomeier Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be another similar leftover further down at

class TutorialLayerArtist(LayerArtist):
_layer_artist_cls = TutorialLayerState
def __init__(self, *args, **kwargs):
super(MyLayerArtist, self).__init__(*args, **kwargs)
self.state.add_callback('fill', self._on_fill_change)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bmorris3 would you have time to make the change to super(TutorialLayerArtist, self) there as well, along with @Carifio24's suggestion? Then we could get this fixed in the same PR.

@dhomeier dhomeier added the documentation Improvements or additions to documentation label Mar 25, 2025
@dhomeier dhomeier changed the title possible docs fix Fixed changed class names in custom viewer docs Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants