Skip to content
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

from_shell=False does not display the colorsphere #2

Open
rec opened this issue Oct 16, 2021 · 4 comments
Open

from_shell=False does not display the colorsphere #2

rec opened this issue Oct 16, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@rec
Copy link
Owner

rec commented Oct 16, 2021

The same problem exists with the original code, but here's a demo with slightly newer code.

If from_shell=True, everything works fine. If from_shell=False, then you can see another application is started, and then you see the numbers from 0 to 19 printed, but you do not see the colorsphere.

Moving these two lines out of the if statement makes no apparent difference.

@rec rec added the enhancement New feature or request label Oct 16, 2021
@rec rec self-assigned this Oct 16, 2021
@rec rec added this to the Beta milestone Oct 16, 2021
@Anders-Holst
Copy link
Collaborator

I think that you are fighting against matplotlib now.

I used it in two different situations: As a standalone app started from a shell, doing only the colorwphere stuff. Then from_shell is true, and matplotlib can steal the main thread, so interactive is disabled (pyplot.ioff) and instead display it explicitely (pyplot.show).

The other situation is that I start a python shell where I test and play with various commands. Then from_sell is False, which means that matplotlib is in interactive mode (runs in its separate thread), and it comes up and I can play.

However, you want to let the python code continue, doing other stuff, after the colorsphere is spawned. That should be possible somehow, but I am not exactly sure how. I think the problem is that the window is not shown until the code signals that it has done what it needs to do to the figure. Matplotlib is lazy in that way, to avoid redrawing while the figures might still be changed. One cue is when you reach the python prompt. You figured that "sleep" would be another cue (and so would I have assumed). Apparently there must be some other call withing matplotlib instead. I don't have it in my head.

(Did I mention that I am really a C++ guy, who really hate python. So many packages are just spagetti and one has to google a lot to find out how to do. And there may be thousands of ways to do the same thing, but only one of them is the right way...)

@rec
Copy link
Owner Author

rec commented Oct 16, 2021 via email

@Anders-Holst
Copy link
Collaborator

You might be right - I thought that matplotlib was running in its own thread in interactive mode, but that seems not to be the case: When I tried to start the colorpicker from the python shell it works fine, but if I then do sleep(20) in the python shell, the colorpicker stops responding. So its actually the same thread. Well, should be straightforward to spin off a separate thread then I suppose?
But do we need in general? How will it typically be used?

@rec
Copy link
Owner Author

rec commented Oct 17, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants