-
Notifications
You must be signed in to change notification settings - Fork 1
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
Comments
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...) |
Oh, I know how to do it - you start a new thread and run in that - but it's
a drag when your main thread is owned by someone else and you're running on
a secondary thread.
The standard way to do this is to run another process!
I wrote C++ for a couple of decades, and I still love it in a crazy
defective sort of way, but I can make much, much faster progress writing in
Python and I can write a much more polished result...
…On Sat, Oct 16, 2021 at 5:24 PM Anders-Holst ***@***.***> wrote:
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...)
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#2 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB53MQWEVGOIZTN4EZ7ZBTUHGKJXANCNFSM5GDSJOFQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
/t
PGP Key: ***@***.***
*https://tom.ritchford.com <https://tom.ritchford.com>*
*https://tom.swirly.com <https://tom.swirly.com>*
|
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? |
The simplest idea is that someone in a library will ask the user to pick a
color, or want a continuous stream of colors, and pop up this colorsphere,
and then go back to their program and receive callbacks elsewhere in their
code.
colorsphere(my_callback)
Quite likely that call would have been generated from a menu pull down or a
button on their API.
Also, you might well want to have two colorspheres going at once - say, one
for background and one for foreground.
…On Sat, Oct 16, 2021 at 7:59 PM Anders-Holst ***@***.***> wrote:
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?
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#2 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB53MQEWUW34EDI2AWYOF3UHG4RJANCNFSM5GDSJOFQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
--
/t
PGP Key: ***@***.***
*https://tom.ritchford.com <https://tom.ritchford.com>*
*https://tom.swirly.com <https://tom.swirly.com>*
|
The same problem exists with the original code, but here's a demo with slightly newer code.
If
from_shell=True
, everything works fine. Iffrom_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.
The text was updated successfully, but these errors were encountered: