From: Dima K. <gn...@di...> - 2018-08-17 20:15:44
|
Hi. I'm looking for a feature that (I think) doesn't exist currently. Want to ask first, in case something DOES exist that I'm not seeing. A number of applications that make plots use gnuplot as a backend. The sequence you want there is: 1. User says "make a plot" 2. Application tells gnuplot to make a plot 3. gnuplot does its thing using an interactive terminal (x11, qt, wxt, ...) and a plot window pops up 4. user looks at the plot, then closes the window when they're done, and wants to continue using the application The issue here is that currently the application (parent of the "gnuplot" process) has no way of knowing when the user finished looking at the plot, which necessitates ugly workarounds. For instance with gnuplotlib I can write a script that just makes a plot. If I just call gnuplotlib.plot(), then the application will make a plot and then exit immediately. As a workaround I put a sleep(10000) after the plot() call. I'd like to have some sort of gnuplotlib.wait() that blocks until gnuplot is done. Maybe gnuplot can be asked to print something on the console when the client window is closed, or something? Thoughts? |
From: Ethan A M. <sf...@us...> - 2018-08-17 20:44:16
|
On Friday, August 17, 2018 1:15:24 PM PDT Dima Kogan wrote: > Hi. > > I'm looking for a feature that (I think) doesn't exist currently. Want > to ask first, in case something DOES exist that I'm not seeing. This ought to be a FAQ or something. The command you are looking for is pause mouse close Recent discussion has indicated that on some systems in may also be necessary add a bind command bind "Close" "exit gnuplot" pause mouse close gnuplot will exit when the user closes the plot window. If you want gnuplot to signal the parent application via some side channel rather rather than exiting , that's a bit trickier. There are several options but the details are OS dependent. For example (not necessary the best option) bind "Close" "system('kill -SIGCONT $PARENTID')" Ethan > A number of applications that make plots use gnuplot as a backend. The > sequence you want there is: > > 1. User says "make a plot" > > 2. Application tells gnuplot to make a plot > > 3. gnuplot does its thing using an interactive terminal (x11, qt, wxt, > ...) and a plot window pops up > > 4. user looks at the plot, then closes the window when they're done, and > wants to continue using the application > > The issue here is that currently the application (parent of the > "gnuplot" process) has no way of knowing when the user finished looking > at the plot, which necessitates ugly workarounds. For instance with > gnuplotlib I can write a script that just makes a plot. If I just call > gnuplotlib.plot(), then the application will make a plot and then exit > immediately. As a workaround I put a sleep(10000) after the plot() call. > I'd like to have some sort of gnuplotlib.wait() that blocks until > gnuplot is done. Maybe gnuplot can be asked to print something on the > console when the client window is closed, or something? Thoughts? |
From: Daniel J S. <dan...@ie...> - 2018-08-17 21:07:10
|
On 08/17/2018 03:15 PM, Dima Kogan wrote: > Hi. > > I'm looking for a feature that (I think) doesn't exist currently. Want > to ask first, in case something DOES exist that I'm not seeing. > > A number of applications that make plots use gnuplot as a backend. The > sequence you want there is: > > 1. User says "make a plot" > > 2. Application tells gnuplot to make a plot > > 3. gnuplot does its thing using an interactive terminal (x11, qt, wxt, > ...) and a plot window pops up > > 4. user looks at the plot, then closes the window when they're done, and > wants to continue using the application > > The issue here is that currently the application (parent of the > "gnuplot" process) has no way of knowing when the user finished looking > at the plot, which necessitates ugly workarounds. For instance with > gnuplotlib I can write a script that just makes a plot. If I just call > gnuplotlib.plot(), then the application will make a plot and then exit > immediately. As a workaround I put a sleep(10000) after the plot() call. > I'd like to have some sort of gnuplotlib.wait() that blocks until > gnuplot is done. Maybe gnuplot can be asked to print something on the > console when the client window is closed, or something? Thoughts? Does "gnuplot --persist" work for your needs? In the following, the gnuplot_qt process hangs around until the window is closed: @linux ~ $ gnuplot --persist G N U P L O T Version 5.3 patchlevel 0 last modified 2018-04-26 Copyright (C) 1986-1993, 1998, 2004, 2007-2018 Thomas Williams, Colin Kelley and many others gnuplot home: http://www.gnuplot.info mailing list: gnu...@li... faq, bugs, etc: type "help FAQ" immediate help: type "help" (plot window: hit 'h') Terminal type is now 'qt' Options are '0 font "Sans,9"' gnuplot> system "ps -e | grep gnuplot" 6680 pts/1 00:00:00 gnuplot gnuplot> plot 1/x gnuplot> system "ps -e | grep gnuplot" 6680 pts/1 00:00:00 gnuplot 6690 ? 00:00:00 gnuplot_qt gnuplot> exit @linux ~ $ ps -e | grep gnuplot 6690 ? 00:00:00 gnuplot_qt @linux ~ $ (manually close window) manually: command not found @linux ~ $ ps -e | grep gnuplot @linux ~ $ |
From: Dima K. <gn...@di...> - 2018-08-19 03:02:42
|
Ethan A Merritt <sf...@us...> writes: > On Friday, August 17, 2018 1:15:24 PM PDT Dima Kogan wrote: >> >> I'm looking for a feature that (I think) doesn't exist currently. Want >> to ask first, in case something DOES exist that I'm not seeing. > > The command you are looking for is > pause mouse close > > Recent discussion has indicated that on some systems in may also be > necessary add a bind command > bind "Close" "exit gnuplot" > pause mouse close > > gnuplot will exit when the user closes the plot window. > > If you want gnuplot to signal the parent application via some side channel > rather rather than exiting , that's a bit trickier. > There are several options but the details are OS dependent. > For example (not necessary the best option) > > bind "Close" "system('kill -SIGCONT $PARENTID')" Ooh, that looks like what I want. Thanks! Will try it out at some point. Daniel: --persist isn't quite what I want. I'd like gnuplot to stay alive, and to tell me when the client window has gone away. For the record, it's for this: https://github.com/dkogan/gnuplotlib |
From: Dima K. <gn...@di...> - 2018-08-20 03:25:43
|
Dima Kogan <gn...@di...> writes: > Ethan A Merritt <sf...@us...> writes: > >> On Friday, August 17, 2018 1:15:24 PM PDT Dima Kogan wrote: >>> >>> I'm looking for a feature that (I think) doesn't exist currently. Want >>> to ask first, in case something DOES exist that I'm not seeing. >> >> The command you are looking for is >> pause mouse close This works in its most basic form, which is awesome. Thanks! But I'm now going to be a pain in the butt. For a gnuplot-using application to work reasonably, this needs to only wait for a window-close event when one is coming: i.e. when a window is open. Scenarios that could happen: 1. User already closed the window before I send my "pause mouse close" 2. We're using a non-interactive terminal (dumb, pdf, etc etc) Ideas on handling that? |
From: sfeam <sf...@us...> - 2018-08-20 04:11:15
|
On Sunday, 19 August 2018 20:25:24 Dima Kogan wrote: > Dima Kogan <gn...@di...> writes: > > > Ethan A Merritt <sf...@us...> writes: > > > >> On Friday, August 17, 2018 1:15:24 PM PDT Dima Kogan wrote: > >>> > >>> I'm looking for a feature that (I think) doesn't exist currently. Want > >>> to ask first, in case something DOES exist that I'm not seeing. > >> > >> The command you are looking for is > >> pause mouse close > > This works in its most basic form, which is awesome. Thanks! But I'm now > going to be a pain in the butt. For a gnuplot-using application to work > reasonably, this needs to only wait for a window-close event when one is > coming: i.e. when a window is open. Scenarios that could happen: > > 1. User already closed the window before I send my "pause mouse close" That sounds like a case of "well then don't do that". If the parent program sends the plot command and the pause command in immediate succession the time window in which that race could happen would be very small. If the commands do not come in immediate succession then maybe the program logic needs re-thinking. Can you give a more complete example of the flow of events? > 2. We're using a non-interactive terminal (dumb, pdf, etc etc) > Ideas on handling that? So far as I know, in that case the next <\n> in the input stream will terminal the "pause" command. Does that not work for you? Ethan |
From: Dima K. <gn...@di...> - 2018-08-20 06:52:20
|
sfeam <sf...@us...> writes: > On Sunday, 19 August 2018 20:25:24 Dima Kogan wrote: >> Dima Kogan <gn...@di...> writes: >> >> > Ethan A Merritt <sf...@us...> writes: >> > >> >> On Friday, August 17, 2018 1:15:24 PM PDT Dima Kogan wrote: >> >>> >> >>> I'm looking for a feature that (I think) doesn't exist currently. Want >> >>> to ask first, in case something DOES exist that I'm not seeing. >> >> >> >> The command you are looking for is >> >> pause mouse close >> >> This works in its most basic form, which is awesome. Thanks! But I'm now >> going to be a pain in the butt. For a gnuplot-using application to work >> reasonably, this needs to only wait for a window-close event when one is >> coming: i.e. when a window is open. Scenarios that could happen: >> >> 1. User already closed the window before I send my "pause mouse close" > > That sounds like a case of "well then don't do that". > If the parent program sends the plot command and the pause command > in immediate succession the time window in which that race could happen > would be very small. If the commands do not come in immediate > succession then maybe the program logic needs re-thinking. > Can you give a more complete example of the flow of events? > >> 2. We're using a non-interactive terminal (dumb, pdf, etc etc) >> Ideas on handling that? > > So far as I know, in that case the next <\n> in the input stream > will terminal the "pause" command. Does that not work for you? I played with it a bit more just now, and it's good-enough. It would be NICE if "pause mouse close" could know if there's anything to potentially wait for, but I guess I don't strictly need it. Thanks much. This will fix a long-standing annoyance with gnuplotlib |
From: sfeam <sf...@us...> - 2018-08-20 15:48:19
|
On Sunday, 19 August 2018 23:52:05 Dima Kogan wrote: > sfeam <sf...@us...> writes: > > > On Sunday, 19 August 2018 20:25:24 Dima Kogan wrote: > >> Dima Kogan <gn...@di...> writes: > >> > >> > Ethan A Merritt <sf...@us...> writes: > >> > > >> >> On Friday, August 17, 2018 1:15:24 PM PDT Dima Kogan wrote: > >> >>> > >> >>> I'm looking for a feature that (I think) doesn't exist currently. Want > >> >>> to ask first, in case something DOES exist that I'm not seeing. > >> >> > >> >> The command you are looking for is > >> >> pause mouse close > >> > >> This works in its most basic form, which is awesome. Thanks! But I'm now > >> going to be a pain in the butt. For a gnuplot-using application to work > >> reasonably, this needs to only wait for a window-close event when one is > >> coming: i.e. when a window is open. Scenarios that could happen: > >> > >> 1. User already closed the window before I send my "pause mouse close" > > > > That sounds like a case of "well then don't do that". > > If the parent program sends the plot command and the pause command > > in immediate succession the time window in which that race could happen > > would be very small. If the commands do not come in immediate > > succession then maybe the program logic needs re-thinking. > > Can you give a more complete example of the flow of events? > > > >> 2. We're using a non-interactive terminal (dumb, pdf, etc etc) > >> Ideas on handling that? > > > > So far as I know, in that case the next <\n> in the input stream > > will terminal the "pause" command. Does that not work for you? > > I played with it a bit more just now, and it's good-enough. It would be > NICE if "pause mouse close" could know if there's anything to > potentially wait for, but I guess I don't strictly need it. If you have identified a sequence of reasonable events that causes gnuplot to lock up entirely, I would consider that a bug. In the case of "pause mouse" I agree that if you issue this command in the state that the current terminal is mouseable but the most recent plot window has been closed then you have a potential lock-up. I say "potential" because from a normal terminal session you can break the lock by typing Ctrl-C. This resets error and pause conditions and returns you to the gnuplot command line. However, if gnuplot is being run from some non-terminal controlling process I am not entirely clear on who would have to send SIGINT (Ctrl-C) to whom. I don't understand you usage scenario well enough to guess. Does the user who is operating the mouse also have a terminal window open? If Ctrl-C is typed in that window, what process receives the signal? Ethan > Thanks much. This will fix a long-standing annoyance with gnuplotlib |