-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ENH, MAINT] Refactor pyvistaqt/notebook widgets abstraction #10803
Conversation
Here's the progress on this: The following works on a notebook:
and the following works with
On the way, I've found several bugs, many things that aren't implemented and don't raise a not implemented error and lots of cruft e.g.
Here's what I'm thinking; with a couple days of fixing, I think it could reimplement all the GUIs with this object-oriented programming but like @larsoner said, this has been established for maybe a year or more so we'd lose all the stability from that and I'm also at the point where I've learned a lot about metaclasses, both the backends and inheritance that this was a nice exercise whereas continuing on is just implementing it so it's a crossroads moment as far as either seeing it out and doing a hopefully not-too-painful rewrite of the widgets implementation or abandoning it and just picking our fights. On one hand, I think the code written this way would 1) be less than half the lines of code 2) be much, much easier to add another backend, even though I don't see one coming, the As far as the other option of abandoning, it's a lot of work for a couple days and I have other things to do so even though I've put in several hours thus far, I'm not opposed. I am really assured after looking into it that moving the I would like to hear input as this would be a PR that rewrote large portions of the backend and so should probably have someone reviewing which will be somewhat time-intensive. That being said, if I continue, I filmed the videos so that I would be comfortable with the function of the |
Oh I forgot a brief summary of what I did to get things to work:
In summary, because the style is changing, things might look a little bit different, other than for the EDIT: One last thing that I thought would be nice but will be on a separate PR is to hide the main GUI when popups happen and then vice versa when you close so that you don't get this long output of windows stacking up. That would also fix the color picker for the |
@alexrockhill do I read it correctly that your preference is to refactor/rewrite the GUI abstraction code? If so, can you comment below #10779 (comment) with what the new structure would look like? At the end of the day I'm okay with a big refactor as long as
One way forward would be for you to put in a couple/few days of effort toward a refactoring then reassess. If it's 1-2 weeks of work in the end and much more maintainable/usable it's worth it, but if it's 1 month of work and things end up no more reliable than before, it's better we stop after a couple of days of trying. |
Great, complete agreement, I'll give it a couple days and see if I can get the GUIs working. The structure is the same as for ipywidgets and Qt; there is a widget class and all the individual widgets inherit from it, ensuring consistent and DRY shared methods. There's really no more to it than that. |
Okay, major progress, took a couple days longer than expected, partly because a few things weren't working on This code successfully executes all widgets used in In
In
Since the code is exactly the same (minus a few outputs for the printlines which won't be in the widgets because they log to the console/mostly don't rely on printing), the GUI should be able to look fairly similar on both backends instead of having very different backend implementation (half of the This should be the hardest part, now I just need to:
A bit of a caveat that almost made me throw up my hands and give up on the |
One option that might make this reasonable from a review standpoint would be:
If the code in that blog used to work but doesn't now, it seems like a MWE to post as a matplotlib issue. They are usually pretty quick to respond, and it seems like getting their canvas(es) to play nicely with ipywidget layouts would be core functionality. |
Sounds good, for 1 should I just use different file names for now? E.g. _notebook2 |
Also it seems to work here so it could be I'm just missing a bit of magic https://matplotlib.org/ipympl/examples/full-example.html. |
Different filenames are fine, sure |
_Renderer
to be a _Window
but allow _Window
s without a _Renderer
Ok, I got to here with reimplementing the I'm going to close this PR for now and open another one that just adds the backend to the existing Per my conversation on Discord with @drammock and @hoechenberger, it would be nice if this backend was eventually used for I think the abstraction will be super useful for GSoC so that the TFR and indirectly the |
Sounds good, if you convinced @drammock and @hoechenberger then I'm convinced by proxy :) |
One more point of housekeeping: @larsoner, what do you think about making the |
Yes I think we should make more stuff in |
Fixes part of #10779, implemented in the hierarchical method described there, in short:
coreg
,brain
timeviewer andieeg_locate
)