Tkinter GUIでコマンドラインの変更をリアルタイムで表示しようとしていますが、GUIを作成してターミナルを組み込むことができましたが、ターミナルでボタンをバインドできません、私のコードは次のとおりです。Tkinter GUIのターミナルに書き込む
import Tkinter
from Tkinter import *
import subprocess
import os
from os import system as cmd
WINDOW_SIZE = "600x400"
top = Tkinter.Tk()
top.geometry(WINDOW_SIZE)
def helloCallBack():
print "Below is the output from the shell script in terminal"
subprocess.call('perl /projects/tfs/users/$USER/scripts_coverage.pl', shell=True)
def BasicCovTests():
print "Below is the output from the shell script in terminal"
subprocess.call('perl /projects/tfs/users/$USER/basic_coverage_tests.pl', shell=True)
def FullCovTests():
print "Below is the output from the shell script in terminal"
subprocess.call('perl /projects/tfs/users/$USER/basic_coverage_tests.pl', shell=True)
Scripts_coverage = Tkinter.Button(top, text ="Scripts Coverage", command = helloCallBack)
Scripts_coverage.pack()
Basic_coverage_tests = Tkinter.Button(top, text ="Basic Coverage Tests", command = BasicCovTests)
Basic_coverage_tests.pack()
Full_coverage_tests = Tkinter.Button(top, text ="Full Coverage Tests", command = FullCovTests)
Full_coverage_tests.pack()
termf = Frame(top, height=100, width=500)
termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()
os.system('xterm -into %d -geometry 100x20 -sb &' % wid)
def send_entry_to_terminal(*args):
"""*args needed since callback may be called from no arg (button)
or one arg (entry)
"""
cmd("%s" % (BasicCovTests))
top.mainloop()
#
私はさてあなたは、少なくとも右のモジュールであり、それは、端末
こんにちは、 あなたの返事をお寄せいただきありがとうございます。私はPython GUIで開いた端末内のperlスクリプトの出力を見たいと思います – user1941008
はい、私はあなたが何をしようとしていると思うここで行うこと。ウィンドウ内に端末を生成したいのであれば、 'os.system()'の代わりに 'subprocess.Popen()'を使用してみてください。少なくとも、あなたのpythonプログラムとxtermプロセスの間にはリンクがあります。 – pholtz
PythonプログラムでPopenオブジェクトが参照されると、 'Popen.communicate()'を使って端末と通信することができます。私はあなたがここで解決しようとしている問題についてもっと考えるのを手伝っています。 – pholtz