I'm trying to open a tex file from within python, tell the tex editor to run (manually you would press ctrl + T) and finally close the program.
So far I can only figure out how to open and close the program.
this is what I have so far...
os.spawnv(os.P_WAIT, r"C:\Program Files\MiKTeX 2.9\miktex\bin\miktex-texworks.exe", ('miktex-texworks' , dir_dst + temp3 + temp2 + '.tex'))
Edited 4 Years Ago by imixkumuku
If you're using a unix-based operating system (aka not windows), you can use the subprocess module to execute shell commands. In effect, you would run latex at the command line through Python.
Looks like you are using windows though so I'm not quite sure. Sorry
:( yeah, I'm using Windows. Nonetheless, I found a way to control an external windows program! However, I would like to program a way for the program to tell python that it is done with its process and then for python to close the program. So far I have this:
shell = win32com.client.Dispatch("WScript.Shell") shell.Run(dir_dst '.tex') sleep(4) shell.SendKeys("^t", 1) sleep(8) shell.SendKeys("^q", 1)
The only problem with it is that some files take longer to process and python moves on before the external program is done. Any idea on how I could fix this?
If your goal is to run a program from Python as in your original post, the only way I think of that working is that you call the program from a script like I mentioned. This can be done in windows if you are able to somehow call latex from the cmd line. Once you do this, you should be able to write a script in whatever language windows cmd line scripts are written in, then have python call that script as you did in the original post.
Let me ask you this... what exactly are you doing this for? I use latex and may be able to help you get around having to write a script in the first place. Secondly, latex I beleive has its own macro language so you may be able to write this script within latex itself. Last, you may want to consider downloading ubuntuu and installing it side-by-side of your windows build. Operations like what you are trying to do as well as many other situations you will likely encounter are more elegantly handled in a unix-based system, and the solutions are more likely to be scattered around the web.
I also should point out that if you do end up finding a way to use the python package "subprocess" the subprocess.call method knows to wait until the process is finished automoatically.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...