From: Guy K. K. <g....@ma...> - 2009-06-28 01:01:59
|
Hi, as some may have noticed, I also run VPython with many things in batch mode. Unfortunately I've just hit a bump doing so. I introduced another layer for batching some computations/visualisations. So I'm wrapping my module and calling it repeatedly with changing parameters in a batch. Unfortunately when I'm doing that for me VPython "misbehaves". I cannot seem to find a way to discard a previous scene to create a new one. Whenever I just do it naively, I get this error: RuntimeError: Cannot change parameters of an active window As the new scene is being initialised with window title, size, ... I've already tried to retrieve the current scene with my_scene = visual.display.get_selected() And then set its visibility to False: my_scene.visible = False In this case the program just stalls and needs to be killed from another console. Or I try to delete the scene instance using: del my_scene or del visual.scene Which doesn't do anything as apparently visual.scene is a static module variable that cannot be discarded. Any ideas on how to make use of it in a sensible way without having to manually create new processes for each sample just to discard the scene? Guy -- Guy K. Kloss Institute of Information and Mathematical Sciences Te Kura Pūtaiao o Mōhiohio me Pāngarau Massey University, Albany (North Shore City, Auckland) 473 State Highway 17, Gate 1, Mailroom, Quad B Building voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 G....@ma... http://www.massey.ac.nz/~gkloss |
From: Jamie R. <jam...@gm...> - 2009-06-28 05:50:35
|
I believe setting scene.visible to false just makes the scene invisible, it doesn't delete it, unlike objects. If you'd like to reinitialize the scene then just delete all visible objects: for obj in scene.objects: On Sat, Jun 27, 2009 at 5:29 PM, Guy K. Kloss <g....@ma...> wrote: > Hi, > > as some may have noticed, I also run VPython with many things in batch > mode. > Unfortunately I've just hit a bump doing so. I introduced another layer for > batching some computations/visualisations. So I'm wrapping my module and > calling it repeatedly with changing parameters in a batch. Unfortunately > when > I'm doing that for me VPython "misbehaves". I cannot seem to find a way to > discard a previous scene to create a new one. Whenever I just do it > naively, I > get this error: > > RuntimeError: Cannot change parameters of an active window > > As the new scene is being initialised with window title, size, ... > > I've already tried to retrieve the current scene with > > my_scene = visual.display.get_selected() > > And then set its visibility to False: > > my_scene.visible = False > > In this case the program just stalls and needs to be killed from another > console. Or I try to delete the scene instance using: > > del my_scene > > or > > del visual.scene > > Which doesn't do anything as apparently visual.scene is a static module > variable that cannot be discarded. > > Any ideas on how to make use of it in a sensible way without having to > manually create new processes for each sample just to discard the scene? > > Guy > > -- > Guy K. Kloss > Institute of Information and Mathematical Sciences > Te Kura Pūtaiao o Mōhiohio me Pāngarau > Massey University, Albany (North Shore City, Auckland) > 473 State Highway 17, Gate 1, Mailroom, Quad B Building > voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 > G....@ma... http://www.massey.ac.nz/~gkloss > > > ------------------------------------------------------------------------------ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: Jamie R. <jam...@gm...> - 2009-06-28 05:51:51
|
Sorry, here's the rest... for obj in scene.objects: obj.visible = false 2009/6/27 Jamie Riotto <jam...@gm...> > I believe setting scene.visible to false just makes the scene invisible, it > doesn't delete it, > unlike objects. If you'd like to reinitialize the scene then just delete > all visible objects: > > for obj in scene.objects: > > > > > On Sat, Jun 27, 2009 at 5:29 PM, Guy K. Kloss <g....@ma...>wrote: > >> Hi, >> >> as some may have noticed, I also run VPython with many things in batch >> mode. >> Unfortunately I've just hit a bump doing so. I introduced another layer >> for >> batching some computations/visualisations. So I'm wrapping my module and >> calling it repeatedly with changing parameters in a batch. Unfortunately >> when >> I'm doing that for me VPython "misbehaves". I cannot seem to find a way to >> discard a previous scene to create a new one. Whenever I just do it >> naively, I >> get this error: >> >> RuntimeError: Cannot change parameters of an active window >> >> As the new scene is being initialised with window title, size, ... >> >> I've already tried to retrieve the current scene with >> >> my_scene = visual.display.get_selected() >> >> And then set its visibility to False: >> >> my_scene.visible = False >> >> In this case the program just stalls and needs to be killed from another >> console. Or I try to delete the scene instance using: >> >> del my_scene >> >> or >> >> del visual.scene >> >> Which doesn't do anything as apparently visual.scene is a static module >> variable that cannot be discarded. >> >> Any ideas on how to make use of it in a sensible way without having to >> manually create new processes for each sample just to discard the scene? >> >> Guy >> >> -- >> Guy K. Kloss >> Institute of Information and Mathematical Sciences >> Te Kura Pūtaiao o Mōhiohio me Pāngarau >> Massey University, Albany (North Shore City, Auckland) >> 473 State Highway 17, Gate 1, Mailroom, Quad B Building >> voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 >> G....@ma... http://www.massey.ac.nz/~gkloss >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Visualpython-users mailing list >> Vis...@li... >> https://lists.sourceforge.net/lists/listinfo/visualpython-users >> > > |
From: Guy K. K. <g....@ma...> - 2009-06-28 06:38:38
|
On Sun, 28 Jun 2009 17:51:47 Jamie Riotto wrote: > I believe setting scene.visible to false just makes the scene invisible, it > doesn't delete it, unlike objects. If you'd like to reinitialize the scene > then just delete all visible objects: > > for obj in scene.objects: > obj.visible = false That ought to be "False". But that also doesn't work, as visual.scene is the object that complains about re-initialised, and that one is a module level variable, so it can only be initialised once per running Python process. Iterating over the objects and setting their visibility to False should (A) just hide them, but not delete them, and (B) still leave the current scene's instance in the state it's in. So that's not helpful, either. I did help myself by checking whether visible.scene.title has been changed, and if so then to hide all objects and not re-initialise the scene. But that's more of a dirty hack, rather than a real solution. It just targets this *one* case, and cannot be generally used for other modules using visual as it would be expectable from Python code. Guy -- Guy K. Kloss Institute of Information and Mathematical Sciences Te Kura Pūtaiao o Mōhiohio me Pāngarau Massey University, Albany (North Shore City, Auckland) 473 State Highway 17, Gate 1, Mailroom, Quad B Building voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 G....@ma... http://www.massey.ac.nz/~gkloss |
From: Jamie R. <jam...@gm...> - 2009-06-28 20:22:31
|
On Sat, Jun 27, 2009 at 11:38 PM, Guy K. Kloss <g....@ma...> wrote: > > On Sun, 28 Jun 2009 17:51:47 Jamie Riotto wrote: > > I believe setting scene.visible to false just makes the scene invisible, it > > doesn't delete it, unlike objects. If you'd like to reinitialize the scene > > then just delete all visible objects: > > > > for obj in scene.objects: > > obj.visible = false > > That ought to be "False". But that also doesn't work, as visual.scene is the > object that complains about re-initialised, and that one is a module level > variable, so it can only be initialised once per running Python process. > > Iterating over the objects and setting their visibility to False should (A) > just hide them, but not delete them, and (B) still leave the current scene's > instance in the state it's in. So that's not helpful, either. Guy, I understand my suggestion didn't fix your problem, but as to your point (A), that setting visiblity to False should hide objects and not delete them, from the VPython Docs: Deleting an Object To delete a Visual object just make it invisible: ball.visible = 0 (Not that I agree with the behavior, I'd prefer being able to make things visible and invisible at will without having to manage the invisible objects (i.e. deleted) myself) Cheers - jamie |
From: Bruce S. <Bru...@nc...> - 2009-06-28 15:59:46
|
There does seem to be a bug, but it's easy to make it work properly. Consider this: d = display() box() my_scene = visual.display.get_selected() my_scene.mouse.getclick() my_scene.visible = False # makes invisible but does not delete print my_scene del my_scene # should get rid of it completely ##d = display() sphere(pos=(2,0,0)) # this should create a new scene, but no window appears print visual.display.get_selected() # shows the same ID as before The cure is to uncomment the second display() statement, and then it works as expected. In other words, don't rely on the default "scene" mechanism but make your own displays if you are going to manipulate those displays. I'm worried that something's apparently wrong with the del statement, which should have gotten rid of the first display completely. I'll look into that. Setting all the objects to invisible before making the display invisible doesn't change anything. Bruce Sherwood Guy K. Kloss wrote: > Hi, > > as some may have noticed, I also run VPython with many things in batch mode. > Unfortunately I've just hit a bump doing so. I introduced another layer for > batching some computations/visualisations. So I'm wrapping my module and > calling it repeatedly with changing parameters in a batch. Unfortunately when > I'm doing that for me VPython "misbehaves". I cannot seem to find a way to > discard a previous scene to create a new one. Whenever I just do it naively, I > get this error: > > RuntimeError: Cannot change parameters of an active window > > As the new scene is being initialised with window title, size, ... > > I've already tried to retrieve the current scene with > > my_scene = visual.display.get_selected() > > And then set its visibility to False: > > my_scene.visible = False > > In this case the program just stalls and needs to be killed from another > console. Or I try to delete the scene instance using: > > del my_scene > > or > > del visual.scene > > Which doesn't do anything as apparently visual.scene is a static module > variable that cannot be discarded. > > Any ideas on how to make use of it in a sensible way without having to > manually create new processes for each sample just to discard the scene? > > Guy > > |
From: Guy K. K. <g....@ma...> - 2009-06-28 20:08:20
|
Hi Bruce, thanks for the explanations, I'll give it a try. I think whenever I set the visual.scene.visible = False my program stopped. It was a very strange behaviour. It was like there's still an event loop or so going from the GUI, and the only way to terminate the process was through an explicit kill. I need to have a look at it again. On Mon, 29 Jun 2009 03:59:02 Bruce Sherwood wrote: > I'm worried that something's apparently wrong with the del statement, > which should have gotten rid of the first display completely. I'll look > into that. Setting all the objects to invisible before making the > display invisible doesn't change anything. I've seen things like that before, wrapping native code in Python. I believe it's got more to do with the C side of things rather than the Python side. Python's del only acts on things that live in the Python world, and it does not/cannot call memory frees, destructors, etc. in the shared library's native code world. What I've done on ctypes based projects before was to add cleaning code to the Python object's __del__ method that performs some native code cleaning on deleting the Python object. Guy -- Guy K. Kloss Institute of Information and Mathematical Sciences Te Kura Pūtaiao o Mōhiohio me Pāngarau Massey University, Albany (North Shore City, Auckland) 473 State Highway 17, Gate 1, Mailroom, Quad B Building voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 G....@ma... http://www.massey.ac.nz/~gkloss |
From: Bruce S. <Bru...@nc...> - 2009-06-28 23:15:29
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> I guess the documentation needs to be more clear, in that it's using the word "delete" too informally. But it is important to note the full statement:<br> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"> <p class="Normal" style="margin: 6pt 0pt 0pt; display: block; text-align: justify; text-indent: 0pt; font-size: 10pt; color: rgb(0, 0, 0); text-decoration: none; vertical-align: baseline; text-transform: none; font-family: sans-serif;">To delete a Visual object just make it invisible:<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball.visible = 0</span></p> <p class="Normal" style="margin: 6pt 0pt 0pt; display: block; text-align: justify; text-indent: 0pt; font-size: 10pt; color: rgb(0, 0, 0); text-decoration: none; vertical-align: baseline; text-transform: none; font-family: sans-serif;">Technical detail: If you later re-use the name<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball</span>, for example by creating a new object and naming it <span class="attribute" style="color: rgb(255, 0, 0);">ball</span>, Python will be free to release the memory used by the object formerly named<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball</span><span class="Apple-converted-space"> </span>(assuming no other names currently refer to that object).</p> </span><br> Probably the first sentence should be replaced by this: "To hide a Visual object just make it invisible: ball.visible = 0. This does not delete the information about the object from the computer's memory, since you can at a later time make it visible again by setting ball.visible = 1."<br> <br> Additional technical point: Python maintains a reference count on objects, with the policy that if the reference count goes to zero the object can be deleted from memory, as there is no longer any way to refer to it. A Visual object has one additional reference count associated with the fact that some human may be looking at the object if it is "visible", which is why you have to make an object invisible (which decrements the reference count) before you can get it fully deleted.<br> <br> Bruce Sherwood<br> <br> Jamie Riotto wrote: <blockquote cite="mid:958...@ma..." type="cite"> <pre wrap="">On Sat, Jun 27, 2009 at 11:38 PM, Guy K. Kloss <a class="moz-txt-link-rfc2396E" href="mailto:g....@ma..."><g....@ma...></a> wrote: </pre> <blockquote type="cite"> <pre wrap="">On Sun, 28 Jun 2009 17:51:47 Jamie Riotto wrote: </pre> <blockquote type="cite"> <pre wrap="">I believe setting scene.visible to false just makes the scene invisible, it doesn't delete it, unlike objects. If you'd like to reinitialize the scene then just delete all visible objects: for obj in scene.objects: obj.visible = false </pre> </blockquote> <pre wrap="">That ought to be "False". But that also doesn't work, as visual.scene is the object that complains about re-initialised, and that one is a module level variable, so it can only be initialised once per running Python process. Iterating over the objects and setting their visibility to False should (A) just hide them, but not delete them, and (B) still leave the current scene's instance in the state it's in. So that's not helpful, either. </pre> </blockquote> <pre wrap=""><!----> Guy, I understand my suggestion didn't fix your problem, but as to your point (A), that setting visiblity to False should hide objects and not delete them, from the VPython Docs: Deleting an Object To delete a Visual object just make it invisible: ball.visible = 0 (Not that I agree with the behavior, I'd prefer being able to make things visible and invisible at will without having to manage the invisible objects (i.e. deleted) myself) Cheers - jamie ------------------------------------------------------------------------------ _______________________________________________ Visualpython-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Vis...@li...">Vis...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/visualpython-users">https://lists.sourceforge.net/lists/listinfo/visualpython-users</a> </pre> </blockquote> </body> </html> |
From: Guy K. K. <g....@ma...> - 2009-06-29 01:24:39
|
On Mon, 29 Jun 2009 11:28:22 Bruce Sherwood wrote: > Here's what I've put into the documentation at vpython.org (and will go > into the documentation that is installed locally for Visual): > > > To hide a Visual object just make it invisible: ball.visible = 0. This does > not delete the object from computer memory, and you can make it visible > again later. > > If however you later re-use the name ball, for example by creating a new > object and naming it ball, Python will be free to release the memory used > by the object formerly named ball (assuming no other names currently refer > to that object). If the object is visible when you re-use the name ball, > the original object will not be deleted from computer memory, and it will > remain visible in the window. > > Suggestions for improvement? You might want to add something how to explicitly delete items as well. E. g. to remove them *now* call "del foobar" after setting the object to "obj.visible = False". BTW, I'd also suggest to use "ball.visible = False" rather than "... = 0". The boolean nature is much more expressive, and it also implies that you don't have a "value" there, which could be interpreted as visible = 0.5 is like opacity and makes it only half visible. This change would remove ambiguity straight off the bat. Guy -- Guy K. Kloss Institute of Information and Mathematical Sciences Te Kura Pūtaiao o Mōhiohio me Pāngarau Massey University, Albany (North Shore City, Auckland) 473 State Highway 17, Gate 1, Mailroom, Quad B Building voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 G....@ma... http://www.massey.ac.nz/~gkloss |
From: Bruce S. <Bru...@nc...> - 2009-06-28 23:28:22
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> Here's what I've put into the documentation at vpython.org (and will go into the documentation that is installed locally for Visual):<br> <br> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"> <p class="Normal" style="margin: 6pt 0pt 0pt; display: block; text-align: justify; text-indent: 0pt; font-size: 10pt; color: rgb(0, 0, 0); text-decoration: none; vertical-align: baseline; text-transform: none; font-family: sans-serif;">To hide a Visual object just make it invisible:<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball.visible = 0</span>. This does not delete the object from computer memory, and you can make it visible again later.</p> <p class="Normal" style="margin: 6pt 0pt 0pt; display: block; text-align: justify; text-indent: 0pt; font-size: 10pt; color: rgb(0, 0, 0); text-decoration: none; vertical-align: baseline; text-transform: none; font-family: sans-serif;">If however you later re-use the name<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball</span>, for example by creating a new object and naming it<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball</span>, Python will be free to release the memory used by the object formerly named<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball</span><span class="Apple-converted-space"> </span>(assuming no other names currently refer to that object). If the object is visible when you re-use the name<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball</span>, the original object will not be deleted from computer memory, and it will remain visible in the window.</p> </span><br> Suggestions for improvement?<br> <br> Bruce Sherwood<br> <br> Bruce Sherwood wrote: <blockquote cite="mid:4A4...@nc..." type="cite"> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> I guess the documentation needs to be more clear, in that it's using the word "delete" too informally. But it is important to note the full statement:<br> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"> <p class="Normal" style="margin: 6pt 0pt 0pt; display: block; text-align: justify; text-indent: 0pt; font-size: 10pt; color: rgb(0, 0, 0); text-decoration: none; vertical-align: baseline; text-transform: none; font-family: sans-serif;">To delete a Visual object just make it invisible:<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball.visible = 0</span></p> <p class="Normal" style="margin: 6pt 0pt 0pt; display: block; text-align: justify; text-indent: 0pt; font-size: 10pt; color: rgb(0, 0, 0); text-decoration: none; vertical-align: baseline; text-transform: none; font-family: sans-serif;">Technical detail: If you later re-use the name<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball</span>, for example by creating a new object and naming it <span class="attribute" style="color: rgb(255, 0, 0);">ball</span>, Python will be free to release the memory used by the object formerly named<span class="Apple-converted-space"> </span><span class="attribute" style="color: rgb(255, 0, 0);">ball</span><span class="Apple-converted-space"> </span>(assuming no other names currently refer to that object).</p> </span><br> Probably the first sentence should be replaced by this: "To hide a Visual object just make it invisible: ball.visible = 0. This does not delete the information about the object from the computer's memory, since you can at a later time make it visible again by setting ball.visible = 1."<br> <br> Additional technical point: Python maintains a reference count on objects, with the policy that if the reference count goes to zero the object can be deleted from memory, as there is no longer any way to refer to it. A Visual object has one additional reference count associated with the fact that some human may be looking at the object if it is "visible", which is why you have to make an object invisible (which decrements the reference count) before you can get it fully deleted.<br> <br> Bruce Sherwood<br> <br> Jamie Riotto wrote: <blockquote cite="mid:958...@ma..." type="cite"> <pre wrap="">On Sat, Jun 27, 2009 at 11:38 PM, Guy K. Kloss <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:g....@ma..."><g....@ma...></a> wrote: </pre> <blockquote type="cite"> <pre wrap="">On Sun, 28 Jun 2009 17:51:47 Jamie Riotto wrote: </pre> <blockquote type="cite"> <pre wrap="">I believe setting scene.visible to false just makes the scene invisible, it doesn't delete it, unlike objects. If you'd like to reinitialize the scene then just delete all visible objects: for obj in scene.objects: obj.visible = false </pre> </blockquote> <pre wrap="">That ought to be "False". But that also doesn't work, as visual.scene is the object that complains about re-initialised, and that one is a module level variable, so it can only be initialised once per running Python process. Iterating over the objects and setting their visibility to False should (A) just hide them, but not delete them, and (B) still leave the current scene's instance in the state it's in. So that's not helpful, either. </pre> </blockquote> <pre wrap=""><!----> Guy, I understand my suggestion didn't fix your problem, but as to your point (A), that setting visiblity to False should hide objects and not delete them, from the VPython Docs: Deleting an Object To delete a Visual object just make it invisible: ball.visible = 0 (Not that I agree with the behavior, I'd prefer being able to make things visible and invisible at will without having to manage the invisible objects (i.e. deleted) myself) Cheers - jamie ------------------------------------------------------------------------------ _______________________________________________ Visualpython-users mailing list <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Vis...@li...">Vis...@li...</a> <a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/visualpython-users">https://lists.sourceforge.net/lists/listinfo/visualpython-users</a> </pre> </blockquote> <pre wrap=""> <hr size="4" width="90%"> ------------------------------------------------------------------------------ </pre> <pre wrap=""> <hr size="4" width="90%"> _______________________________________________ Visualpython-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Vis...@li...">Vis...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/visualpython-users">https://lists.sourceforge.net/lists/listinfo/visualpython-users</a> </pre> </blockquote> </body> </html> |
From: Bruce S. <Bru...@nc...> - 2009-06-29 21:36:14
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=UTF-8" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> Makes sense; thanks. I considered saying something about del but for no good reason didn't. <br> <br> I should go through all the docs and change 1/0 to True/False. The history is that in 2000 Python didn't have True/False. At some point Scherer implemented true=1 and false=0, but the documentation didn't exploit this. And then even later True/False got added to Python; I don't remember when that happened.<br> <br> Bruce Sherwood<br> <br> Guy K. Kloss wrote: <blockquote cite="mid:200...@ma..." type="cite"> <pre wrap="">On Mon, 29 Jun 2009 11:28:22 Bruce Sherwood wrote: </pre> <blockquote type="cite"> <pre wrap="">Here's what I've put into the documentation at vpython.org (and will go into the documentation that is installed locally for Visual): To hide a Visual object just make it invisible: ball.visible = 0. This does not delete the object from computer memory, and you can make it visible again later. If however you later re-use the name ball, for example by creating a new object and naming it ball, Python will be free to release the memory used by the object formerly named ball (assuming no other names currently refer to that object). If the object is visible when you re-use the name ball, the original object will not be deleted from computer memory, and it will remain visible in the window. Suggestions for improvement? </pre> </blockquote> <pre wrap=""><!----> You might want to add something how to explicitly delete items as well. E. g. to remove them *now* call "del foobar" after setting the object to "obj.visible = False". BTW, I'd also suggest to use "ball.visible = False" rather than "... = 0". The boolean nature is much more expressive, and it also implies that you don't have a "value" there, which could be interpreted as visible = 0.5 is like opacity and makes it only half visible. This change would remove ambiguity straight off the bat. Guy </pre> </blockquote> </body> </html> |
From: Guy K. K. <g....@ma...> - 2009-06-29 22:55:23
|
On Tue, 30 Jun 2009 09:36:14 Bruce Sherwood wrote: > I should go through all the docs and change 1/0 to True/False. The history > is that in 2000 Python didn't have True/False. At some point Scherer > implemented true=1 and false=0, but the documentation didn't exploit this. > And then even later True/False got added to Python; I don't remember when > that happened. True and False were added as built in constants in Python 2.3: http://docs.python.org/library/constants.html -- Guy K. Kloss Institute of Information and Mathematical Sciences Te Kura Pūtaiao o Mōhiohio me Pāngarau Massey University, Albany (North Shore City, Auckland) 473 State Highway 17, Gate 1, Mailroom, Quad B Building voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 G....@ma... http://www.massey.ac.nz/~gkloss |