Below is all the code for this program, it's very small and simple currently:
from Tkinter import * import os class EmacsLauncher(Frame): def __init__(self): """Set up Graphical User Interface Frame.""" Frame.__init__(self) self.master.title("Emacs Launcher") self.grid() self._label1 = Label(self, text = "File:") self._label1.grid(row = 0, column = 0) self._fileTextVar = StringVar() self._fileText = Entry(self, textvariable = self._fileTextVar) self._fileText.grid(row = 0, column = 1) self._launchButton = Button(self, text = "Launch", command = self._launch) self._launchButton.grid(row = 1, column = 1) def _launch(self): """Open the _fileTextVar file in Emacs""" filePath = "emacs " + str(self._fileTextVar) os.popen(filePath, "w") def main(): """Run main loop""" EmacsLauncher().mainloop() main()
Basically all the code is just setting up the GUI, and the main point of interest are these lines below:
filePath = "emacs " + str(self._fileTextVar) os.popen(filePath, "w")
What happens when I run this code is that the program with open Emacs as if you entered just "emacs" in the terminal. What I was under the impression that os.popen() should do is open Emacs, but with the filename. For instance, if one was to enter "emacs example.py" into the terminal. I've browsed the link below as it contains documentation of the os.popen() function, however, I just can't seem to make heads or tails of it.
Python v2.7.1 Documentaion
If anyone has some insight for me, it would be greatly appreciated!