0
使用http://pygtk.org/pygtk2tutorial/examples/filelisting.py如何通过点击它来让用户在外部程序中打开文件(总是相同,特别是像sox这样的无GUI界面的音频播放器)?在python中打开一个文件
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
我想这个片段大约只有上市文件... 这将是我的第一个Python程序,所以请多多包涵,如果我的问题是愚蠢的:)
他可能想要在后台启动它,这意味着他将创建'subprocess.Popen'并在将来处理它(除非他想产生一个线程来等待'call'返回) ......但是阅读你所链接的“子过程”文档应该足以让他朝着正确的方向前进,所以远远不够好。 – abarnert
'subprocess.call([“play”,“〜/ Studio/Samples/DRUMS/Vintage_Drum_Samples_24bit/DR55/dr55_rim.wav”])'就像魅力一样,谢谢!现在我只需要弄清楚如何在pyGTK中触发点击事件,以及如何将这个subprocess.call绑定到它。 – yPhil
http://www.pygtk.org/pygtk2tutorial/sec-EventHandling.html – Hyperboreus