From: Andrey A. <an...@uc...> - 2006-03-06 16:58:29
|
Dear Friends, All of us enjoy the VPython environment. Little by little gaining the experience we want to create some scripts in Python for building one or more scenes full of objects. I am a math high school teacher. It would be better for my (or our) students to save their scenes and use them in their next lessons. To be more specific I mean saving the scene in a file for example using the output of the command: scene.objects Could anyone help me to solve this problem. Any hints, links ang suggestions are welcome. I joined the VPython user list from last May 2005 and didn't meet discussions on this topic. ThX in advance Andrio Math teacher |
From: Dethe E. <de...@li...> - 2006-03-07 21:53:18
|
On 3/7/06, Andrey Antonov <an...@uc...> wrote: > Dear Lady Elza, Um, not even close, but I'll let that slide. > Your letter impressed me much, because it is obvious that you are (from m= y > PoV) a programmer, > or closely connected with programming. I'm a professional programmer at my day job, a hobbyist programmer in my spare time. > I am not a professional programmer, but I have some experience in > programming. > I mean, up to a certain extent I could think :)) in algorithmic way. Mayb= e > because I am a math teacher, or for other reasons, I don't know... There are similarities between programming and math. > Your idea : > """ > You would probably have to walk the tree of objects and convert the > state of each object to a string which, when run, would restore the > original object. Tedious, but not difficult.""" > > is very brilliant and frankly speaking it was the first that came to my m= ind Not really brilliant, pretty much a standard approach. > trying to search my way to > solve the the problem I asked about. It is strange now, after receiving t= he > letter from Bruce, that this topic > haven't been discussed yet between VPython users. For the most part I think people test small bits of code at the command-line and write programs to create larger amounts of code.=20 What I think you want is to build up small bits of code, then to save the state of all of it? There are several approaches which would work, for one, you could just save each line of code to a file before executing it, to have a log of commands which could be re-run to recreate your state. You could have undo by dropping commands off the end of the file. Or, as in my previous post, you could build up a scene, then walk the tree of objects and write out equivalent commands. VPython object constructors can take arguments for pretty much any aspect of their state, so if you have a sphere which is green, with a radius of 2 at location (4,7,8) in the scene, you could write out from visual import * sphere(color=3D(0,1,0), radius=3D2, pos=3D(4,7,8)) Of course, you would have to do this for every type of object that VPython supports, and for every property of each object--and I'm not positive that they are all covered by named arguments. Overall it would be easier to write the files as you go. > Going ahead I ask myself questions for: > 1) bulding the tree of objects and relations between them from the point= of > view of "children and parents objects". Not sure what you mean here. Is what I mention above what you mean? > 2) Also it is closely related to the problem for executing a list of UNDO > commands in order the reach the beginning state of the program or in my c= ase > it is equal in restoring the starting state of the scene. Undo support would almost certainly be influenced by what mechanism you're using to build the environment. I do most of my work on OS X using its Cocoa framework, and Cocoa already has a notion of documents. Working with the standard Cocoa documents you can get a lot of behaviour (loading, saving, prompting to save before exit, undo/redo, etc.) without much work. Implementing it all from scratch is do-able, but much more work, and runs the substantial risk of it not working like other programs (which defeats user expectations). > Could you give me some links to e-books or web sources for mentioned abov= e > questions. I don't have a clear enough idea of what you're trying to do. The python.org website has good pointers for improving your python skills. If you want to create a UI for your students, you'll need to pick a user interface toolkit. This could be Tkinter, which has a good book on it, or wxPython (I think a book is in progress, but not sure of the status). I use Cocoa, but it is OS X only and has no book (yet).=20 There are other options... I don't think VPython integrates with any of the UI frameworks, but I've written VPython programs which communicate to a Tkinter UI via sockets. I hope that helps. --Dethe > Of course looking for the answers is for the next version of the program.= If > the first version wll see the world :)) > > Thank you again > Andrio > > |
From: Dr P H B. <P.H...@bh...> - 2006-03-06 22:02:11
|
You do not say what system you are using, but MS has the PrtScr key (to right of F12), which saves the whole screen to the clipboard, whence you can save it to a file. Alt/PrtScr saves the current window This may be too obvious, but PrtScr is one of the better hidden features of the keyboard. Regards Peter In message <001001c6413f$57dffd00$93e61ec1@mitkoandrey> "Andrey Antonov" <an...@uc...> wrote: > Dear Friends, > > All of us enjoy the VPython environment. Little by little gaining the > experience we want to create some scripts in Python for building one or more > scenes full of objects. > I am a math high school teacher. It would be better for my (or our) students > to save their scenes and use them in their next lessons. To be more specific > I mean saving the scene in a file for example using the output of the > command: > scene.objects > Could anyone help me to solve this problem. Any hints, links ang suggestions > are welcome. > I joined the VPython user list from last May 2005 and didn't meet > discussions on this topic. > > ThX in advance > > Andrio > Math teacher > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users -- Dr P H Borcherds |<mailto:P.H...@bh...> |phone 0044 (0)121 475 3029 |
From: Dethe E. <de...@li...> - 2006-03-06 23:30:46
|
VPython doesn't have a built-in way to save the state as a python program. It shouldn't be terribly hard to create one, but there isn't anything built-in as far as I know. Unfortunately, VPython objects don't appear to be picklable (because the underlying Boost objects are not pickleable), so you can't even use the shortcut method of saving your state with the shelve module. You would probably have to walk the tree of objects and convert the state of each object to a string which, when run, would restore the original object. Tedious, but not difficult. -Dethe On 3/6/06, Andrey Antonov <an...@uc...> wrote: > Dear Friends, > > All of us enjoy the VPython environment. Little by little gaining the > experience we want to create some scripts in Python for building one or m= ore > scenes full of objects. > I am a math high school teacher. It would be better for my (or our) stude= nts > to save their scenes and use them in their next lessons. To be more speci= fic > I mean saving the scene in a file for example using the output of the > command: > scene.objects > Could anyone help me to solve this problem. Any hints, links ang suggesti= ons > are welcome. > I joined the VPython user list from last May 2005 and didn't meet > discussions on this topic. > > ThX in advance > > Andrio > Math teacher > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: <bas...@nc...> - 2006-03-07 04:43:00
|
As can be seen by the differing responses, it isn't clear whether you are trying to save images (which on Windows can be done by pressing Alt-PrintScreen, which put a bitmap image in the copy buffer, from which it can be pasted into a word processor) or you are trying to save object information (which as explained would require a lot of programming). I'm left wondering exactly what problem you're trying to solve. Presumably students have access to their previous programs, which contain all of the information. They can be run again to regenerate images, and they obviously contain all the object information. Please offer a bit more context for what the issue is. Thanks. Bruce Sherwood > Dear Friends, > > All of us enjoy the VPython environment. Little by little gaining the > experience we want to create some scripts in Python for building one or > more > scenes full of objects. > I am a math high school teacher. It would be better for my (or our) > students > to save their scenes and use them in their next lessons. To be more > specific > I mean saving the scene in a file for example using the output of the > command: > scene.objects > Could anyone help me to solve this problem. Any hints, links ang > suggestions > are welcome. > I joined the VPython user list from last May 2005 and didn't meet > discussions on this topic. > > ThX in advance > > Andrio > Math teacher > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |