#1
|
|||
|
|||
starting Vizard from a Python script
I would like to run a Vizard script from another Python script by something like
os.execv("winviz.exe",['runthisVizardscript.py']) but when I try this, I get a dialog box that says Vizard must be running first. Also, when I click the 'ok' button, it seems to hang up the Pythonwin program.... Normally, I would not be using Pythonwin but the calling script would be executed from the Command prompt or equivalent. Any thoughts on how I can do this? Thanks in advance. |
#2
|
|||
|
|||
Hi,
To run a Vizard script from the command line you need to execute 'Vizard.exe' and pass the file name and "-r" as the arguments. This will basically open up the main Vizard program and immediatley run the specified script. Here's an example: C:\Program Files\Vizard\bin\Vizard C:\myscript.py -r One thing to note, if there are spaces in the name of your script path you need to inclose it within quotes: C:\Program Files\Vizard\bin\Vizard "C:\my script.py" -r Good Luck! -- farshid |
#3
|
|||
|
|||
Thanks. That works like a charm! I think you put the quotes around the wrong part of the command in your example.... As a follow-up, is there a clean way to exit Vizard as well? I can exit the graphics portion with viz.quit() but is there a way to also exit Vizard.exe without using the menu option? |
#4
|
|||
|
|||
Hi,
Currently there is no way to exit the main vizard program with a command, but I can easily add this feature for the next release. For now you can do the following, which basically finds the handle to the vizard window and sends a close message to it: import win32ui VizardWindow = win32ui.FindWindow("WorldvizVizardClass",None) VizardWindow.SendMessage(16,0,0) Hope that helps! -- farshid |
#5
|
|||
|
|||
Thanks for the workaround - although I discovered that I had to make sure that the Pythonwin package was installed to have access to the win32ui module. I was not running the python script via Vizard although, I suspect that I will do this eventually.
Thanks also for putting this feature into the list for the next release. |
#6
|
|||
|
|||
Oops - one more comment to my previous post. My Vizard script protests when I try to include the win32ui methods, or at least, I cannot use them after a call to vrut.quit() (It's in part of a keyboard event handler routine). If I don't use vrut.quit() then it seems to run ok. Will the future command allow me to shut down all windows?
|
#7
|
|||
|
|||
Hi,
Once vrut.quit() is called the program stops execution, that's why the win32ui commands aren't being called. Try running the win32ui commands before vrut.quit(). This should work fine since the main vizard program is a separate process than the winviz program. So your keyboard handler should look something like this: def mykeyboard(key): if key == 'q': import win32ui window = win32ui.FindWindow('WorldvizVizardClass',None) window.SendMessage(16,0,0) vrut.quit() Hope that works! -- farshid |
#8
|
|||
|
|||
OK, that did the trick - thanks!
Andy |
#9
|
|||
|
|||
v1.09 include this type of quit
Just wondering if this functionality made it into v1.09? I can still use the workaround, but curious if there is a new method like
viz.quitall() that handles it nicely? Thanks Andy |
#10
|
|||
|
|||
Hi Andy,
There is no built in way of closing the main Vizard application, but you can pass it the '-e' flag through the command line to make it exit. This is probably nicer than the previous way, however I'll just go ahead and implement a "quitall()" method while I'm at it. =) -- farshid |
#11
|
|||
|
|||
Is this "quitall()" functionality now included in Vizard 2.50 or 2.51? I would like to be able to close Vizard.exe from within a Vizard script.
|
#12
|
|||
|
|||
The command will not work. It was created before the ability to launch a script from outside the GUI. Here is the code for it if you still need it:
Code:
def quitall(): #Send '-e' flag to vizard to make it exit path = _WIN_VIZ_PATH #Make sure vizard_path exists if len(path) > 0: if path[-1] != '\\': path += '\\' path += 'bin\\Vizard.exe" -e' path = '"' + path os.system(path) #Now quit winviz quit() |
#13
|
|||
|
|||
hey,
is there a build-in function for closing the application by now? thanks! |
Thread Tools | |
Display Modes | Rate This Thread |
|
|