-
Notifications
You must be signed in to change notification settings - Fork 50
Plot frame #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plot frame #313
Conversation
0d6b766
to
88f33c3
Compare
This is working now with Now onto Qt output context and toolbar. |
Everything works on my end, I tested every combination with ipywidgets, sidecar/no sidecar, Qt, and with ImageWidget. Right now the toolbar implementations are quite repetitive, we can make that nicer in a future PR after we have some time to think about it. Someone must have made a common interface between ipywidgets and Qt that we can use. qt.mp4 |
self.output = (frame.canvas, *add_widgets) | ||
|
||
if make_toolbar: # make toolbar and stack canvas, toolbar, add_widgets | ||
self.toolbar = IpywidgetToolBar(frame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if ImageWidget? where is logic for if plot type is imagewidget?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImageWidget
just uses the Gridplot
context:
def show(self, toolbar: bool = True, sidecar: bool = False, sidecar_kwargs: dict = None):
"""
Show the widget
Returns
-------
OutputContext
"""
if self.gridplot.canvas.__class__.__name__ == "JupyterWgpuCanvas":
self._image_widget_toolbar = IpywidgetImageWidgetToolbar(self)
elif self.gridplot.canvas.__class__.__name__ == "QWgpuCanvas":
self._image_widget_toolbar = QToolbarImageWidget(self)
return self.gridplot.show(
toolbar=toolbar,
sidecar=sidecar,
sidecar_kwargs=sidecar_kwargs,
add_widgets=[self._image_widget_toolbar]
)
did you update the requirements file? |
Another thing I see is that when I have two subplots in an imagewidget and the camera y_scales are opposite that when I change click between subplots the flip button is not changing in accordance with the camera y_scale...just stays the same |
No dependency changes here. |
In ipywidgets or Qt? |
ipwidgets |
not even if someone only wants qt? they would need to have pyqt6 installed right? |
Qt land is a bit complicated, so they will have to install Qt themselves separately. We can do toggles later, because to do this properly we need to give users the option of PySide etc and decide how broad we want this support. |
I think now I see what you mean, it is wonky! So this is because in ImageWidget all cameras are under one controller. I did not decide how to deal with flipping when controllers are diff. What I will do is if the flip button is clicked, it will flip the camera for the current subplot but also any camera that has the same controller (similar to what I did for panzoom and maintain_aspect). |
closes #310 closes #342 closes #268
This PR adds a
Frame
class that manages how plots are shown.Plot
andGridplot
, and any future flexilbe gridplot, inherit fromFrame
.How this works:
Toolbars
Refactored ipywidget Toolbar that is common between Plot, Gridplot and any future gridplots
Output Contexts
These are classes that "hold" the output of a Plot/Gridplot. They determine how the canvas, toolbar, and any additional widgets are shown. When
Plot.show()
is called, they return an instance of one of the following output contexts based on the curent plot canvas.JupyterOutputContext
ipywidgets.VBox
and contains the canvas, toolbar, and any other widgets. Manages sidecar if desired.QOutputContext
QWidget
, contains the canvas, qt toolbar, and any other widgets.This cleans up the messy
show()
calls we previously had everywhere, and cleans up other stuff too. Now the output context manages closing plots too.BTW, the
QOutputContext
can also be used in notebooks with if you execute%gui qt
before creating plots 😄