-
Notifications
You must be signed in to change notification settings - Fork 12
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
Problem with viewer
variable with multiple viewers and consolas
#40
Comments
I'm confused by the concepts here.
and I was quite shocked when neither v1 nor v2 worked in either console. Other than a script the other way to get in a 2 viewer shared state is to launch napari from the terminal, which has a console, and use that console to make another viewer. |
After you open console in second viewer, did you try to interact with first viewer via console? |
Yeah like @psobolewskiPhD, I don't understand why #18 didn't result in v1 and v2 being injected into the namespace... I think fixing that is more important than the workaround in #41 (though thank you @dalthviz!), and indeed I would remove the special-casing around the viewer — the viewer should have whatever variable name the script gave it. |
OK i retested this and indeed and it's quite strange! So yeah, the main thing is we need |
@dalthviz Maybe it will be possible to overwrite |
Will give that a try 👍 (maybe doing a
Also, to sumarize the expected behavior, the idea is for the corresponding variables defined in the script to point to their respective viewer while ensuring that the |
If I did
When I open the console of that viewer, Edit: if the user doesn't provide a name, then defaulting to |
Oh so for you the variable in the script is not working? Checking the simple case with only one viewer I'm able to access the viewer via Maybe the variable is working for my due to the way I'm running the script (from a cmd running |
I'm also using
and napari from main. |
I'm being unable to reproduce that behavior :/ (for me the variables over the script work) From what I understand #18 should have enabled the use of script variables in the console, right? Maybe there are some setups/cases where the implementation done there doesn't work? 🤔 Could it be worthy to open a new issue for that then? |
I just did a fresh env,
This works, I can access v1 and my_var from the console. viewer as well. |
I just retested in the new env with
I can access v1 and v2 in either console and both work just fine.
Then jump to v1 console:
Back to v2 console:
The image opened in v1 viewer, despite typing in v2. |
Awesome! 🎉
I opened PR #42 which should take care of that. There the |
I made a fresh dev env: but with napari --info for the one that doesn't work:
|
I was able to reproduce the missing variables when using PyQt6! From a quick check, seems like adding |
Crosslinking: napari/napari#1530 : clobbering |
We inject
viewer
variable into the console to allow a user to interact with the viewer.However, if we have multiple viewers in a single process, the
viewer
variable will point to last viewer where we try to open the console (even if the second console do not show napari/napari#7413, that will be fixed in #39)The variable is defined here:
napari-console/napari_console/qt_console.py
Line 106 in 463f828
It will be nice to find that there is already
viewer
variable defined in console and addviewer1
etc.@dalthviz could you take a look?
The text was updated successfully, but these errors were encountered: