help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scripts close plot windows automatically


From: Nicholas T
Subject: Re: scripts close plot windows automatically
Date: Wed, 19 Mar 2008 18:25:32 -0700

On Wed, Mar 19, 2008 at 5:41 PM, John W. Eaton <address@hidden> wrote:
On 19-Mar-2008, Nicholas T wrote:

|    I would like for a script not to close a plot window. The best I could
| find online was using the pause() function, which is sorta crappy (compared
| to having the user actually close the window). Please tell me if you know a
| better way.
|
| e.g. save the following to a .m file, and execute
| plot([0:0.1:1], [0:0.1:1])

Execute in what way?  From the Octave prompt?  If so, the plot window
stays on the screen after the script is finished and the next Octave
prompt is printed (at least for me).  Maybe you can give a more
precise explanation of what it is you are trying to do?

jwe

no, from the command line, either through octave --eval "script_name" or just octave script_name.m.
I forgot to cc the list in reply to Ben; reply copied below.

Thanks so much,
Nicholas


Hi Ben,

   I'm running 2.9.12 on suse linux. I think you misunderstood me--I don't want octave to close the graph after the script finishes, I want it to close only after the user clicks the close button. I found out that this only occurs when executing octave from the command line; e.g.

echo "plot([0:0.1:1], [0:0.1:1])" > nothing.m && octave nothing.m

   However, if you open octave's shell and type "nothing", the window will stay open until the user closes it. I'm thinking there might be some way to use the "--interactive" and then use the exit() function from within the script by setting something like the window's closerequestfcn, but unfortunately that only seems to be called when the shell exits (rather than when the user closes the window). Code for that below.

function nothing()
    fig = figure()

    plot([0:0.1:1], [0:0.1:1])
    set(gcf, 'closerequestfcn', @close_function)
    get(gcf, 'closerequestfcn')
endfunction

function close_function()
    disp('closing...')
    closereq()
    exit()
endfunction
reply via email to

[Prev in Thread] Current Thread [Next in Thread]