On Sun, December 3, 2006 8:49 pm, belinda thom said:
> Hello,
>
> I'm using the plot utilities that come w/Pyro on Mac OS X (10.4.8)
> and Python 2.4.3. I'm a tkinter newbie.
>
> When I issue the following commands (from Python, not Pyro):
>
> >>> from pyrobot.gui.plot.scatter import Scatter
> >>> p = Scatter(linecount=2,connectPoints=0,xEnd=7.0,yEnd=1.2,legend=
> ["tr","te"],title="NN Gen",width=400)
>
> I get two windows that come up, one that looks like a plotting
> window, the other that is blank and has the title "tk". If I issue
> another Scatter command, I get another window (but not another "tk"
> window). If I close the "tk" window, both plot windows also close.
>
> Is this behavior to be expected? And if not, is this likely a
> platform issue? I'd prefer having a SINGLE plot window open each time
> I give a "Scatter" command.
>
> A bit of context about how Tkinter works in this context could
> perhaps be very helpful to me.
This is normal. The fix is a little tricky, and I'm not sure exactly what
should be done, in general. Here's the issue: A default main window
(sometimes called a "listener" window) is always needed by Tkinter; if you
don't do it manually it will do it automatically. I usually do create it
manually, like so:
>>> import Tkinter
>>> tk = Tkinter.Tk()
Now, you can hide it if you wish:
>>> tk.withdraw()
but it is still there just invisible. Tkinter windows usually take this
root default window as the first argument, and Scatter does:
scatter = Scatter(tk, ...)
and this somehow ties all of the windows together with the same toplevel
window.
Now the problem is: what do you want to have happen when you close the
scatter window? You could override the destroy() method so that it kills
the listener window too (if we saved a handle to it):
def destroy(self):
self.app.destroy()
but you don't always want to shutdown everything (such as if you are
running pyro and just want to shut the scatter plot).
I think the solution might be to make scatter (and similar windows) take a
flag so you can make it close everything when it closes if the flag is
true.
Until that happens, you can:
1. override scatter, and define destroy to kill the root
2. hide the tk window (but that requires that you control+c)
3. leave it showing, and just close both
4. other options?
-Doug
> Thanks,
> --b
> _______________________________________________
> Pyro-users mailing list
> [email protected]
> http://emergent.brynmawr.edu/mailman/listinfo/pyro-users
>
--
Douglas S. Blank
Associate Professor, Bryn Mawr College
http://cs.brynmawr.edu/~dblank/
Office: 610 526 601
_______________________________________________
Pyro-users mailing list
[email protected]
http://emergent.brynmawr.edu/mailman/listinfo/pyro-users