【发布时间】:2017-03-22 07:09:01
【问题描述】:
我是 python 和 tkinter 的新手。
我有一个工作的 tkinter 脚本(我想避免编辑) 现在我正在编写一个将是顶级 GUI 的脚本。 此脚本中的按钮应该使用一些命令行参数启动我现有的脚本(例如从 shell 运行它,即 python3.4.1 script.py args)。
我尝试了以下方法:
-
使用 os.system
btn2 = Button(frame2, text="Configure>>", command="os.system('python script.py args')") -
使用子进程
def runSubProcess(self): p=subprocess.Popen(["python3.4.1","script.py args"],stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output=p.communicate()[0]
这两种方法都不起作用。
欢迎提出任何建议,谢谢。
编辑:我也不需要与新窗口进行通信,因为它将写入稍后将使用的文件。只需将控件从子窗口返回到父窗口就足够了(单击确定后)
-维奈
【问题讨论】:
标签: user-interface tkinter python-3.4