From: Michele M. <mat...@gm...> - 2009-07-02 13:25:56
|
Hello list, I'm trying to figure out how to close visual from the code and not from the GUI, 'cause I need this feature. Consider the following code: import visual import time scene = visual.display() cyl = visual.cylinder() time.sleep(3) scene.visible = False if you run it with python test.py the command line keeps to be busy and the prompt never show up. This does not happen if I click on the x on top of the gui. I'm missing some bit? Regards, Michele. |
From: Bruce S. <Bru...@nc...> - 2009-07-03 04:49:43
|
What platform are you running on? I find that on Windows this does work properly running from a command line. The C++ code does intend to exit the program if we reach the end of the program and there are no windows visible. However, for some reason exit doesn't happen on Ubuntu Linux. I didn't yet try on the Mac. It also does not exit on Windows when running from VIDLE or IDLE, maybe because in the shell window you can still execute statements, such as scene.visible = True, so you're not really at the end of the program. Clearly we need some statement that unequivocally kills the program. Bruce Sherwood Michele Mattioni wrote: > Hello list, > > I'm trying to figure out how to close visual from the code and not > from the GUI, 'cause I need this feature. > > Consider the following code: > > > import visual > import time > scene = visual.display() > cyl = visual.cylinder() > time.sleep(3) > scene.visible = False > > > if you run it with > > python test.py > > the command line keeps to be busy and the prompt never show up. > This does not happen if I click on the x on top of the gui. > > I'm missing some bit? > > Regards, > Michele. > > ------------------------------------------------------------------------------ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: Bruce S. <Bru...@nc...> - 2009-07-03 05:44:51
|
A somewhat distinctive feature of VPython is that there is no exit when you reach the end of a program such as from visual import * sphere() The reason of course is that you may be viewing the scene and spinning or zooming. However, as you imply, if your program has finished and there is no scene to be viewed, VPython should exit. A separate issue is how to programmatically exit a program. I thought there was a way using sys.exit(), but that doesn't work (doesn't seem to work in Visual 3, either). Bruce Sherwood Michele Mattioni wrote: > Hello list, > > I'm trying to figure out how to close visual from the code and not > from the GUI, 'cause I need this feature. > > Consider the following code: > > > import visual > import time > scene = visual.display() > cyl = visual.cylinder() > time.sleep(3) > scene.visible = False > > > if you run it with > > python test.py > > the command line keeps to be busy and the prompt never show up. > This does not happen if I click on the x on top of the gui. > > I'm missing some bit? > > Regards, > Michele. > > ------------------------------------------------------------------------------ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: Michele M. <mat...@gm...> - 2009-07-03 08:34:26
|
On Fri, Jul 3, 2009 at 5:49 AM, Bruce Sherwood<Bru...@nc...> wrote: > What platform are you running on? > > I find that on Windows this does work properly running from a command > line. The C++ code does intend to exit the program if we reach the end > of the program and there are no windows visible. However, for some > reason exit doesn't happen on Ubuntu Linux. I didn't yet try on the Mac. > I'm running Ubuntu Jaunty. > It also does not exit on Windows when running from VIDLE or IDLE, maybe > because in the shell window you can still execute statements, such as > scene.visible = True, so you're not really at the end of the program. > Clearly we need some statement that unequivocally kills the program. > I need to exit programmatically from the visual and close the window. I'm using visual together with another main GUI window, so when I close the main also visual should close properly. When I click on the x in the right corner of the window the program closes in a proper way, so why we don't expose the same method to the python interface? http://visualpython.cvs.sourceforge.net/viewvc/visualpython/vpython-core2/src/gtk2/display.cpp?revision=1.57&view=markup I think the method attached with the on_quit_clicked() (line 240) should do the work.. we can give it a try. On a side note making visual a GtkWidget Visual window would give much more control, a nice integration within the gtk main loop, and more sane event handling. Do you think it is a good idea? Regards, Michele P.S.: The application is this one: http://mattions.github.com/neuronvisio/ > Bruce Sherwood > > Michele Mattioni wrote: >> Hello list, >> >> I'm trying to figure out how to close visual from the code and not >> from the GUI, 'cause I need this feature. >> >> Consider the following code: >> >> >> import visual >> import time >> scene = visual.display() >> cyl = visual.cylinder() >> time.sleep(3) >> scene.visible = False >> >> >> if you run it with >> >> python test.py >> >> the command line keeps to be busy and the prompt never show up. >> This does not happen if I click on the x on top of the gui. >> >> I'm missing some bit? >> >> Regards, >> Michele. >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Visualpython-users mailing list >> Vis...@li... >> https://lists.sourceforge.net/lists/listinfo/visualpython-users >> > > ------------------------------------------------------------------------------ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: Bruce S. <Bru...@nc...> - 2009-07-03 16:17:28
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=UTF-8" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> I checked the Mac, and it behaves correctly, like Windows. It's only Linux that doesn't, and I don't know why.<br> <br> I think you're right that the thing to do is to expose the same method that is driven by clicking on the close box. I might not get to this very soon, as I'm swamped getting out the third edition of a physics textbook on a tight deadline.<br> <br> I don't know enough about GTK widgets to be able to comment on whether your suggestion about widgets is feasible.<br> <br> Bruce Sherwood<br> <br> Michele Mattioni wrote: <blockquote cite="mid:290...@ma..." type="cite"> <pre wrap="">On Fri, Jul 3, 2009 at 5:49 AM, Bruce Sherwood<a class="moz-txt-link-rfc2396E" href="mailto:Bru...@nc..."><Bru...@nc...></a> wrote: </pre> <blockquote type="cite"> <pre wrap="">What platform are you running on? I find that on Windows this does work properly running from a command line. The C++ code does intend to exit the program if we reach the end of the program and there are no windows visible. However, for some reason exit doesn't happen on Ubuntu Linux. I didn't yet try on the Mac. </pre> </blockquote> <pre wrap=""><!----> I'm running Ubuntu Jaunty. </pre> <blockquote type="cite"> <pre wrap="">It also does not exit on Windows when running from VIDLE or IDLE, maybe because in the shell window you can still execute statements, such as scene.visible = True, so you're not really at the end of the program. Clearly we need some statement that unequivocally kills the program. </pre> </blockquote> <pre wrap=""><!----> I need to exit programmatically from the visual and close the window. I'm using visual together with another main GUI window, so when I close the main also visual should close properly. When I click on the x in the right corner of the window the program closes in a proper way, so why we don't expose the same method to the python interface? <a class="moz-txt-link-freetext" href="http://visualpython.cvs.sourceforge.net/viewvc/visualpython/vpython-core2/src/gtk2/display.cpp?revision=1.57&view=markup">http://visualpython.cvs.sourceforge.net/viewvc/visualpython/vpython-core2/src/gtk2/display.cpp?revision=1.57&view=markup</a> I think the method attached with the on_quit_clicked() (line 240) should do the work.. we can give it a try. On a side note making visual a GtkWidget Visual window would give much more control, a nice integration within the gtk main loop, and more sane event handling. Do you think it is a good idea? Regards, Michele P.S.: The application is this one: <a class="moz-txt-link-freetext" href="http://mattions.github.com/neuronvisio/">http://mattions.github.com/neuronvisio/</a> </pre> <blockquote type="cite"> <pre wrap="">Bruce Sherwood Michele Mattioni wrote: </pre> <blockquote type="cite"> <pre wrap="">Hello list, I'm trying to figure out how to close visual from the code and not from the GUI, 'cause I need this feature. Consider the following code: import visual import time scene = visual.display() cyl = visual.cylinder() time.sleep(3) scene.visible = False if you run it with python test.py the command line keeps to be busy and the prompt never show up. This does not happen if I click on the x on top of the gui. I'm missing some bit? Regards, Michele. ------------------------------------------------------------------------------ _______________________________________________ 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> <pre wrap="">------------------------------------------------------------------------------ _______________________________________________ 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> </blockquote> </body> </html> |