简体   繁体   中英

Running shell script through python tkinter

I am making an application through python tkinter; I am not able to understand how I can run a shell script with it.

My use case is , when I press a button it will invoke a shell script and display its output in GUI.

You're looking for the subprocess module:

https://docs.python.org/3/library/subprocess.html

An example:

subprocess.run(["ls"]). # run ls
output = subprocess.check_output(["ls"]) # grab the output of ls

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM