Reputation: 8357
Using http://pygtk.org/pygtk2tutorial/examples/filelisting.py how can I have the user open the file in an external program (always the same, specifically a GUI-less audio player like sox play) by clicking on it ?
def open_file(self, treeview, path, column):
model = treeview.get_model()
iter = model.get_iter(path)
filename = os.path.join(self.dirname, model.get_value(iter, 0))
filestat = os.stat(filename)
if stat.S_ISDIR(filestat.st_mode):
new_model = self.make_list(filename)
treeview.set_model(new_model)
return
I guess this snippet is only about listing the files... This would be my first python program, so please bear with me if my question is dumb :)
Upvotes: 0
Views: 183
Reputation: 32429
You can use subprocess.call
or os.spawn
or any other function that spawns or calls a process. Pass the executables name as an argument and the pass the file name as a CLI argument, as long as the called program (in your case your player) accepts CLI arguments.
Upvotes: 3