<p>It was convenient to have something that bypassed the whole gui issue. Since it really is a gui issue, I am not too offended that my own laziness got in my way. </p>
<p>That said, it seemed to me that the use of the new window was a convenience added for just this kind of use, otherwise I would be using a snip, not just slamming a plot up. When plot-new-window? is #t, the call to plot evaluates to void. So it seems that my use case was the point. Without a reference to the new window, "the opposite problem"---if I understood correctly---can't happen. Can it? </p>
<div class="gmail_quote">On Apr 17, 2012 3:12 PM, "Robby Findler" <<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
FWIW, I think we'd want somehow, in the library, to show plot windows<br>
in a way that doesn't do any special threading/eventspace stuff, or<br>
else the opposite confusion can happen.<br>
<br>
How about, for this situation, having a function called 'show-plot!'<br>
that takes a plot and puts it into a window in a separate eventspace,<br>
collecting all of the plots?<br>
<br>
Robby<br>
<br>
On Tue, Apr 17, 2012 at 1:16 PM, Matthew Flatt <<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>> wrote:<br>
> You could give each frame in its own eventspace.<br>
><br>
> At Tue, 17 Apr 2012 11:45:20 -0600, Neil Toronto wrote:<br>
>> Would it be possible to change plot so that its windows always behave<br>
>> like this? Could I make it not require cooperation from the program that<br>
>> calls `plot-frame'?<br>
>><br>
>> This is going to come up every time someone wants to pop up plot windows<br>
>> in a non-GUI, interactive loop.<br>
>><br>
>> Neil ⊥<br>
>><br>
>> On 04/17/2012 10:48 AM, Matthew Flatt wrote:<br>
>> > All GUI activity like window drawing happens only in the main thread of<br>
>> > an eventspace. Your program also starts out in the main thread. So,<br>
>> > yes, drawing has to wait until your loop completes.<br>
>> ><br>
>> > One solution is to put your loop in a separate thread. The example<br>
>> > below creates a thread and passes it to `yield' to wait until the<br>
>> > thread is done. The `yield' function is special in that it lets other<br>
>> > GUI activity happen while it waits:<br>
>> ><br>
>> > #lang at-exp racket<br>
>> > (require plot<br>
>> > racket/gui/base)<br>
>> > (plot-new-window? #t)<br>
>> > (yield<br>
>> > (thread<br>
>> > (lambda ()<br>
>> > (let loop ()<br>
>> > (let ((dummy (read)))<br>
>> > (if (and (number? dummy) (zero? dummy))<br>
>> > (void)<br>
>> > (begin<br>
>> > (plot (function (λ(x) (* x x)) -2 2))<br>
>> > (loop))))))))<br>
>> ><br>
>> > Although the above should work, it's not really a good idea to perform<br>
>> > GUI actions outside of the main thread. So, here's an improved version<br>
>> > that uses `queue-callback' to send the `plot' call back to the main<br>
>> > thread:<br>
>> ><br>
>> > #lang at-exp racket<br>
>> > (require plot<br>
>> > racket/gui/base)<br>
>> > (plot-new-window? #t)<br>
>> > (yield<br>
>> > (thread<br>
>> > (lambda ()<br>
>> > (let loop ()<br>
>> > (let ((dummy (read)))<br>
>> > (if (and (number? dummy) (zero? dummy))<br>
>> > (void)<br>
>> > (begin<br>
>> > ;; queue a callback instead of `plot' directly:<br>
>> > (queue-callback<br>
>> > (lambda ()<br>
>> > (plot (function (λ(x) (* x x)) -2 2))))<br>
>> > (loop))))))))<br>
>> ><br>
>> > For more information, see<br>
>> ><br>
>> ><br>
>> <a href="http://docs.racket-lang.org/gui/windowing-overview.html#(part._eventspaceinfo)" target="_blank">http://docs.racket-lang.org/gui/windowing-overview.html#(part._eventspaceinfo)</a><br>
>> ><br>
>> ><br>
>> > At Tue, 17 Apr 2012 10:40:55 -0400, Deren Dohoda wrote:<br>
>> >> I was messing around with a spline utility last night and was using<br>
>> >> the plot-new-window? setting to get a plot. The goal was to share an<br>
>> >> exe with a coworker who doesn't have Racket. Just a command-line app<br>
>> >> but to get the plot to display I needed a window and this seemed<br>
>> >> awesome. The problem is I couldn't get the plot to display when the<br>
>> >> thread was in a procedure. The window would appear but it was like the<br>
>> >> plot backend wasn't free to draw to it. Here's a way to reproduce it<br>
>> >> on v5.2:<br>
>> >><br>
>> >> #lang at-exp racket<br>
>> >> (require plot)<br>
>> >> (plot-new-window? #t)<br>
>> >> (let loop ()<br>
>> >> (let ((dummy (read)))<br>
>> >> (if (and (number? dummy) (zero? dummy))<br>
>> >> (void)<br>
>> >> (begin<br>
>> >> (plot (function (λ(x) (* x x)) -2 2))<br>
>> >> (loop)))))<br>
>> >><br>
>> >> So long as you are looping, new windows will appear without plot<br>
>> >> contents. When you finally quit (here by entering the number zero) all<br>
>> >> the plots are drawn in those windows. Any help? Did I do something<br>
>> >> horribly dumb?<br>
>> >><br>
>> >> Thanks,<br>
>> >> Deren<br>
>> >><br>
>> >> ____________________<br>
>> >> Racket Users list:<br>
>> >> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
>> ><br>
>> > ____________________<br>
>> > Racket Users list:<br>
>> > <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
>><br>
>> ____________________<br>
>> Racket Users list:<br>
>> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div>