Comments (15)
My mind is suitably blown.
not to hijack the thread, but here's another revelation:
from qtpy.QtWidgets import QApplication, QPushButton
app = QApplication([])
button = QPushButton("Push Me")
button.clicked.connect(lambda e: print("clicked!"))
button.show() # obviously, not shown yet
app.processEvents() # now you see the button
# buuuuut.... try to click on it.
# it appears that the app has crashed... spinning pinwheel of death
app.processEvents() # 🤯 (prints "clicked!")
app.exec_() # click to your heart's content
# then close the window
# (by default Qt quits the event loop when the last window is gone)
# make a new one
button2 = QPushButton("Push Me2")
button2.clicked.connect(lambda e: print("clicked2!"))
button2.show() # not shown yet
# go nuts
%gui qt
so, %gui qt, and app.exec_()
are just glorified versions of:
while True:
app.processEvents()
from napari.github.io.
Not quite: if it runs while building the docs, it will run as an independent ipython notebook. (That’s one of the whole points we all agree is nice about using Jupyter book here).
@tlambert03 yeah but we'll do stuff like create the viewer, fix the camera settings, (nothing happens), then call nbscreenshot, which will create a viewer window that instantly becomes non-responsive, right? That's not super great user experience for that notebook! 😂
from napari.github.io.
I was trying a fix in #110 but the CI tests are failing, so we'll have to resolve that problem first
from napari.github.io.
Also just want to point out... you don't technically need it there at all (except for possible educational purposes). But I don't think you need to actually execute it (so it could be in a pure markdown cell)
from napari.github.io.
I think the educational purposes are pretty important! Especially if this is no longer a thing.
from napari.github.io.
@GenevieveBuckley I think @tlambert03's point is that the string is not exactly accurate — we don't have to start the event loop before import. We probably should start it before making a viewer, and we must (I think? @tlambert03?) start it before the nbscreenshot
.
So yeah, educational purposes are absolutely critical, we should just make sure we educate correctly — the issue you link to shows that we had a lot of muddled ideas about event loops in napari before, and now that we are sorting them out, we risk confusing a lot of the community.
from napari.github.io.
yep, definitely wasn't trying to diminish the educational purpose. was just trying to point out that, in the context of removing the error (what this post was about), you can just not execute that cell at all and you'll be fine. by "not execute" I don't mean to imply that you need to delete it... that's what I meant by put it in a "pure markdown cell": in other words, let it be part of the narrative if you want to, but if the error you're getting by executing that cell is causing you grief, just don't execute it.
It's only necessary if you want to have an interactive IPython session (which you are not doing here).
we don't have to start the event loop before import.
correct
We probably should start it before making a viewer
totally optional. you can call %gui qt
after making a viewer too and it will show a viewer and not block...
and we must (I think? @tlambert03?) start it before the nbscreenshot.
nope actually. not necessary there either. nbscreenshot will processEvents for you... (this was actually necessary otherwise you'd have no layer list in the viewer)
so, to be clear: you can completely remove %gui qt
here and the docs will be fine. I know I keep referring to it, but have a look at the recent magicgui docs in napari, where I do just that. again, I'm not saying that you should remove all mention of %gui qt
... but you don't need to execute it.
from napari.github.io.
side note: should we have a short zoom session sometime (with anyone interested) to talk about all the confusing Qt things?
from napari.github.io.
nbscreenshot will processEvents for you...
My mind is suitably blown.
should we have a short zoom session sometime (with anyone interested) to talk about all the confusing Qt things?
Yes, probably, plus update the event loop doc, and e.g. link to it when people use napari.gui_qt()
.
from napari.github.io.
@GenevieveBuckley I think @tlambert03's point is that the string is not exactly accurate — we don't have to start the event loop before import. We probably should start it before making a viewer, and we must (I think? @tlambert03?) start it before the
nbscreenshot
.
Ooooh, I see. So we're not arguing about whether there should be an explanation included, it's that the content I've written is incorrect. That's fine, we should replace that with something that is correct. (Which probably means Talley will need to write it, since he understands it best)
from napari.github.io.
so, to be clear: you can completely remove %gui qt here and the docs will be fine. I know I keep referring to it, but have a look at the recent magicgui docs in napari, where I do just that. again, I'm not saying that you should remove all mention of %gui qt... but you don't need to execute it.
But if we remove it and a new user downloads the notebook, they will not be able to run it properly (assuming they launch jupyter with the usual jupyter notebook
command).
I care way less about whether it's strictly necessary to build the docs, and much more about whether we're showing people the same way we expect them to use napari most often.
from napari.github.io.
Yeah, we probably don't need to remove it, but we can e.g. have a link out to the updated docs which should explain everything we just discussed.
from napari.github.io.
But if we remove it and a new user downloads the notebook, they will not be able to run it properly (assuming they launch jupyter with the usual jupyter notebook command).
Not quite: if it runs while building the docs, it will run as an independent ipython notebook. (That’s one of the whole points we all agree is nice about using Jupyter book here).
I’m sorry I’m having difficulty explaining this here. I certainly wasn’t saying to remove it. I was just trying to offer an option for removing the error that opened this post. We can have the discussion about how best to present this to users somewhere else
from napari.github.io.
Ok, to summarize: leave in the gui qt, explain why it’s there. If you’d like to (but you don’t have to!!) you can comment it out and tell people to uncomment it. I’ll open an issue elsewhere where we can discuss how we can simplify this
from napari.github.io.
Given napari/napari#2406 we can probably get rid of the %gui qt
stuff entirely (starting from napari version 0.4.7)
from napari.github.io.
Related Issues (20)
- Link Checker Report
- Click handler highjack modifiers/new tabs. HOT 1
- Link Checker Report
- install(ing)-as-a-bundle-app wrong anchor. HOT 1
- Link Checker Report
- installation page confusing HOT 1
- Google takes users to broken pages HOT 2
- [Search][v0.4.16] Search Results template is broken HOT 2
- [Navigation] Navigation labels are not displayed correctly HOT 2
- Examples Gallery listing repeated multiple times (Safari) HOT 1
- [How to install napari][v0.4.16] Blue boxes are not showing content and do not match with v0.4.15 HOT 2
- Broken links HOT 1
- [4.16][Footer] Footer links disappear when hovering on them HOT 2
- [Contributions Reference] Right menu is in bold when it shouldn't HOT 2
- Bug: search results table is formatted strangely on macOS Safari 16.0, chrome 106 HOT 1
- [0.4.16] Calendar is a jumble on Safari (macOS 12.4): no data HOT 4
- [Meeting Schedule] Calendar is broken HOT 10
- Version switcher drop-down box label and arrow is inconsistent HOT 6
- [dev] website issue: Search bar obscured by top nav bar HOT 4
- [Safari 16.4, macOS] Spinning video on homepage, stable docs only HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from napari.github.io.