我创建了一个在Linux终端中运行命令的GUI。
实施例=> -n 20 -id 15 -domain square(10,20)-dim 2 -o execution -format geo,tess
此命令用于执行包的代码。并且当它在Linux终端中执行一系列输出时。输出成功并生成输出或由于转储错误或错误参数而发生错误。
终端输出示例:
错误:matheval无法处理表达式。表达方式 语法可能不正确。这也可能是由于不合适造成的 matheval安装(表达式= 1 -ori fiber(,,))。中止(核心 倾倒)
另一个错误
错误:参数错误! 中止(核心倾销)
我要做的是将此错误作为MessageBox返回到GUI中,并/或更新GUI的底部状态栏并显示错误。
我不熟悉wx和子进程模块,但到目前为止,我的研究未能找到解决方案。
我正在运行Python 2.7并使用Tkinter。
答案 0 :(得分:0)
这似乎完成了工作。
# Create a string and pass variables
neper_exec = "neper -T -n %s -id %s -format %s -o %s -dim %s -domain %s " % (n, id, output_form, o, dim, domain)
# Execute the subporcess using the variable
p = subprocess.Popen(neper_exec, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # when shell is dropped Linux gives and error
感谢@BrianMcFarland提供有关子进程命令的指导。