我正在使用OS X.我双击我的脚本从Finder运行它.此脚本导入并运行以下函数.
我希望脚本能够显示一个Tkinter打开文件对话框并返回所选文件列表.
这是我到目前为止所拥有的:
def open_files(starting_dir):
"""Returns list of filenames+paths given starting dir"""
import Tkinter
import tkFileDialog
root = Tkinter.Tk()
root.withdraw() # Hide root window
filenames = tkFileDialog.askopenfilenames(parent=root,initialdir=starting_dir)
return list(filenames)
Run Code Online (Sandbox Code Playgroud)
我双击脚本,终端打开,打开Tkinter文件对话框. 问题是文件对话框在终端后面.
有没有办法抑制终端或确保文件对话框最终?
谢谢,韦斯
这一定很容易.我想在OS X上通过shell脚本安装Homebrew.
Homebrew推荐的终端安装工程,
$ ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)
Run Code Online (Sandbox Code Playgroud)
但如果我将以下内容放在test.sh文件中,
#!/bin/sh
ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)
Run Code Online (Sandbox Code Playgroud)
然后执行它,
$ sh test.sh
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
test.sh: line 2: syntax error near unexpected token `('
test.sh: line 2: `ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)'
Run Code Online (Sandbox Code Playgroud)
在shell脚本中使用的正确语法是什么,以使其工作,为什么它与命令行不同?谢谢!