Python OS事件不会在Tkinter中打开文件

时间:2019-07-18 04:47:52

标签: python macos tkinter operating-system

基本上,我试图创建一个事件,该事件由绑定到tkinter列表框的命令调用。我有一个显示在列表框中的文件列表,双击操作应打开/执行该文件。

我想知道它是否可以在Windows操作系统上运行。

def opensystem(event):
    x = lbox.curselection()[0]
    os.system(lbox.get(x))

lbox.bind("<<ListboxSelect>>", showcontent)
lbox.bind("<Double-Button-1>", opensystem)

我希望在Tkinter双击打开文件时使用。 我收到错误

Ollies-MacBook-Pro:Converter oliverkerruish$ python -u "/Users/oliverkerruish/Documents/Converter/Untitled-1.py"
sh: gui.py: command not found
gui.py
sh: Untitled-1.py: command not found
Untitled-1.py
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `Charged Cops Autocheckout Form (Responses) - Template.csv'
Charged Cops Autocheckout Form (Responses) - Template.csv

0 个答案:

没有答案