All, I have created a very q+d-hacked PlotCanvas based on scipy.plt. In case anybody is interested, the bare class file is attached. Feel free to add this to scipy.plt if you see it fit. It requires one patch to scipy.plt itself to access _active from the outside (q+d, as I said!): Index: plt/interface.py =================================================================== RCS file: /home/cvsroot/world/scipy/plt/interface.py,v retrieving revision 1.10 diff -u -r1.10 interface.py --- plt/interface.py 2001/10/12 20:07:08 1.10 +++ plt/interface.py 2001/10/24 15:05:19 @@ -498,3 +498,7 @@ else: p.SetSize(s1) + +def setActive(active): + global _active + _active = active You can also download the code including a small application from my homepage -> homemade software page; it's part of jkext. See files gui/plot.py, gui/kplot.py and scripts/plot. I am planning to add some more functionality and then release this as a small sample app. Greetings, Jochen -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E
Hey Jochen, The figure() method is actually meant for doing this -- although I looked at it and noticed the code was disabled. I've enabled it and rewritten a little in the current CVS. figure() works very much like Matlab's figure. figure() without arguments generates a new figure. If a numerical index is supplied, figure grabs the plot with that index (first plot created has index 0). If an actual plot frame is supplied, that plot is made the active figure. So >>> a = plt.plot((1,2,3)) # generate a figure >>> figure() #generate new figure >>> figure(a) # activate first figure Here figure(a) is equivalent to your setActive(a). One more comment. Please name functions and classes intended for scipy with all lower-case/underscore convention (setActive() --> set_active(). This has been used as uniformly as possible across the entire package (although some things are still getting fixed). thanks, eric More examples:
import gui_thread <wxPython imported> from scipy import plt q=plt.plot((1,2,3)) q.Raise() q <C wxFrame instance at _e28688_wxFrame_p> plt.figure() <C wxFrame instance at _e22c10_wxFrame_p> plt.plot((1,2,3)) <C wxFrame instance at _e22c10_wxFrame_p> plt.figure(0) <C wxFrame instance at _e28688_wxFrame_p> plt.figure(1) <C wxFrame instance at _e22c10_wxFrame_p> plt.figure(q) <C wxFrame instance at _e28688_wxFrame_p>
----- Original Message ----- From: "Jochen Küpper" <jochen@unc.edu> To: "scipy-dev" <scipy-dev@scipy.org> Sent: Wednesday, October 24, 2001 11:13 AM Subject: [SciPy-dev] PlotCanvas
All,
I have created a very q+d-hacked PlotCanvas based on scipy.plt. In case anybody is interested, the bare class file is attached. Feel free to add this to scipy.plt if you see it fit. It requires one patch to scipy.plt itself to access _active from the outside (q+d, as I said!):
Index: plt/interface.py =================================================================== RCS file: /home/cvsroot/world/scipy/plt/interface.py,v retrieving revision 1.10 diff -u -r1.10 interface.py --- plt/interface.py 2001/10/12 20:07:08 1.10 +++ plt/interface.py 2001/10/24 15:05:19 @@ -498,3 +498,7 @@ else: p.SetSize(s1)
+ +def setActive(active): + global _active + _active = active
You can also download the code including a small application from my homepage -> homemade software page; it's part of jkext. See files gui/plot.py, gui/kplot.py and scripts/plot. I am planning to add some more functionality and then release this as a small sample app.
Greetings, Jochen -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E
On Wed, 24 Oct 2001 17:19:03 -0400 eric jones wrote: Eric> The figure() method is actually meant for doing this -- although Eric> I looked at it and noticed the code was disabled. Yeah, I messed with that last night as well. Apparently I was a little sleepy already:( Eric> I've enabled it and rewritten a little in the current CVS. Seen that... Eric> figure() works very much like Matlab's figure. Well, sorry. I think I spent at most 2 hours with matlab, and that is definitely more than 5 years ago:( Eric> [...] Eric> Here figure(a) is equivalent to your setActive(a). Not exactly. What I really need is to tell plt about a new plot_canvas it did't create by itself! Well, you could say I have to smuggle it in:) The way to do that is to extend the "case" in figure() so when which_object is not numeric and not in _figure to check whether type(which_object) == type(<instance of plot_canvas or derived class>) If I understand that correctly something like that is definitely not possible in python < 2.2 (and I am not sure it is possible in 2.2). Well, the attached patch has an even worse hack than all the stuff before, but it does work along the python lines of cooperation:)) Eric> Please name functions and classes intended for scipy with all Eric> lower-case/underscore convention (setActive() --> set_active(). Eric> This has been used as uniformly as possible across the entire Eric> package (although some things are still getting fixed). Fine. Yes I think consistency is most important here -- it's a huge package. One comment from my side: How do you distinguish between classes/types and functions then? (I don't see real evidence for a verb vs. noun scheme either...:). Anyway, there should be something like <scipy>/doc/ProgrammingGuidelines, I would suggest to start with the second attached file and put all "enforced" rules in there. Doesn't have to be very formal (yet), just put in the rules, if they are not clear that *will* be discussed on the list at some point, you can be sure:( Greetings, Jochen PS to Eric: Regarding patching: I think if you are on Windows you should save the patch as DOS-text, not Unix-text? Sorry, I do all this stuff within Cygwin, I really don't get any work like that done in Windoze. -- Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper.de Liberté, Égalité, Fraternité GnuPG key: 44BCCD8E Sex, drugs and rock-n-roll
Not exactly. What I really need is to tell plt about a new plot_canvas it did't create by itself! Well, you could say I have to smuggle it in:)
Ahh, ok.
The way to do that is to extend the "case" in figure() so when which_object is not numeric and not in _figure to check whether type(which_object) == type(<instance of plot_canvas or derived class>)
If I understand that correctly something like that is definitely not possible in python < 2.2 (and I am not sure it is possible in 2.2).
Your hack is fine for now I think. I'll apply the patches.
One comment from my side: How do you distinguish between classes/types and functions then? (I don't see real evidence for a verb vs. noun scheme either...:).
Anyway, there should be something like <scipy>/doc/ProgrammingGuidelines, I would suggest to start with the second attached file and put all "enforced" rules in there. Doesn't have to be very formal (yet), just put in the rules, if they are not clear that *will* be discussed on the list at some point, you can be sure:(
I added your comment to the following page: http://www.scipy.org/site_content/tutorials/formatting_guidelines
PS to Eric: Regarding patching: I think if you are on Windows you should save the patch as DOS-text, not Unix-text? Sorry, I do all this stuff within Cygwin, I really don't get any work like that done in Windoze.
The Mingw32 tool set does suprisingly well at bridging the gap. Sophisticated make files don't work, but much of the other stuff does -- most of the familiar Unix commands are available. I use cygwin some also though, and Unix quite a lot. see ya, eric
On Thu, 25 Oct 2001 09:27:37 -0400 eric jones wrote:
Anyway, there should be something like <scipy>/doc/ProgrammingGuidelines, I would suggest to start with the second attached file and put all "enforced" rules in there. Doesn't have to be very formal (yet), just put in the rules, if they are not clear that *will* be discussed on the list at some point, you can be sure:(
Eric> I added your comment to the following page: Eric> http://www.scipy.org/site_content/tutorials/formatting_guidelines Yeah, nice wording. But something like that, aimed at the scipy developer, should really be in cvs -- as plain text. Working on the source I won't go on the web to check that stuff out. I'll use the editor I am working in already and load the file one dir up (or so). (No, I am not even willing to start w3.) And there are more lazy people like me around:( If you wanna avoid line wraps on 80-char terminals you have to break at col 79, because some editors (*that is* Emacs) wrap lines with exactly 80 text-chars on such displays. Greetings, Jochen -- Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper.de Liberté, Égalité, Fraternité GnuPG key: 44BCCD8E Sex, drugs and rock-n-roll
Good idea. I added a file called FORMAT_GUIDELINES.txt to the CVS. As far as 79 vs. 80 characters, bummer. I didn't know that about emacs. Everything is (supposed to be) in 80 char format now. I guess we could fix this, but it ain't high on my list. eric ----- Original Message ----- From: "Jochen Küpper" <jochen@jochen-kuepper.de> To: <scipy-dev@scipy.org> Sent: Thursday, October 25, 2001 11:26 PM Subject: Re: [SciPy-dev] Re: PlotCanvas
On Thu, 25 Oct 2001 09:27:37 -0400 eric jones wrote:
Anyway, there should be something like <scipy>/doc/ProgrammingGuidelines, I would suggest to start with the second attached file and put all "enforced" rules in there. Doesn't have to be very formal (yet), just put in the rules, if they are not clear that *will* be discussed on the list at some point, you can be sure:(
Eric> I added your comment to the following page:
Eric> http://www.scipy.org/site_content/tutorials/formatting_guidelines
Yeah, nice wording.
But something like that, aimed at the scipy developer, should really be in cvs -- as plain text. Working on the source I won't go on the web to check that stuff out. I'll use the editor I am working in already and load the file one dir up (or so). (No, I am not even willing to start w3.) And there are more lazy people like me around:(
If you wanna avoid line wraps on 80-char terminals you have to break at col 79, because some editors (*that is* Emacs) wrap lines with exactly 80 text-chars on such displays.
Greetings, Jochen -- Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper.de Liberté, Égalité, Fraternité GnuPG key: 44BCCD8E Sex, drugs and rock-n-roll
_______________________________________________ Scipy-dev mailing list Scipy-dev@scipy.net http://www.scipy.net/mailman/listinfo/scipy-dev
On Fri, 26 Oct 2001 11:27:20 -0400 eric jones wrote: eric> Good idea. I added a file called FORMAT_GUIDELINES.txt to the eric> CVS. ok. But why is it all uppercase and with that ugly ".txt" extension? What in the world is wrong with "Format_Guidelines" (or "format_guidelines":)) ??? Not that it really matters:) eric> As far as 79 vs. 80 characters, bummer. PEP 8 eric> I didn't know that about emacs. Well, my emacsens usually have 120--150 chars per line anyway... eric> Everything is (supposed to be) in 80 char format now. I guess we eric> could fix this, but it ain't high on my list. I think there is no urgent need to change existing code, but new one should definitely stick to 79. (Or open it up to 132 (or so) and assuming nobody is using ttys anymore, I think that is not feasible yet:() Greetings, Jochen -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E
----- Original Message ----- From: "Jochen Küpper" <jochen@unc.edu> To: <scipy-dev@scipy.org> Sent: Friday, October 26, 2001 3:32 PM Subject: Re: [SciPy-dev] Re: PlotCanvas
On Fri, 26 Oct 2001 11:27:20 -0400 eric jones wrote:
eric> Good idea. I added a file called FORMAT_GUIDELINES.txt to the eric> CVS.
ok.
But why is it all uppercase and with that ugly ".txt" extension? What in the world is wrong with "Format_Guidelines" (or "format_guidelines":)) ???
Not that it really matters:)
picky, picky. The uppercase is somewhat of a standard for non-code stuff. Travis O. used it for LICENSE, etc. LAPACK and ATLAS both uses it for README, INSTALL, etc. The txt on the end is to be nice to windows users. The OS automatically recognizes that extension and uses the appropriate app to open the file. eric
participants (4)
-
eric jones
-
eric jones
-
Jochen Küpper
-
Jochen Küpper