python - print output of subprocess call into a label tkinter -


i trying create gui in tkinter. gui mcp23017. trying configure input , output pins user change them according choice.. there option make inputs/outputs high or low..

now trying read pin using 'i2cget'(using seperate function).. need display output of subprocess call label on gui..

this code looks like:

def read_p22():    output = subprocess.call(['i2cget -y 0x20 0x12 0xfd'],shell=true)    x=print (output)    label(tableframe,textvariable=x).grid(row=2,column=20)    root.after(5000, read_p22) 

when function excutes(by pressing button), prints value '1' on python shell alternatly when press button... dont know how redirect output label.. suggest something?

update:: on executing suggested commands:

process = subprocess.popen(['i2cget -y 0x20 0x12 0xfd'], stdout=pipe,      stderr=pipe, shell=true) output, code = process.communicate() 

i printed 'output' , 'process' , gave me follwing respectivley:

b'' <subprocess.popen object @ 0x00000000035cb2b0> 

since nothing connected pin expect return value of '0'.. don't know b'' giving me ...

any advice appreciated..

kind regards, namita.

what have return code, not output.

from subprocess.call docs:

run command described args. wait command complete, return returncode attribute.

instead, use subprocess.popen open process, subprocess.pipe pipe output you, , popen.communicate output:

process = subprocess.popen(['i2cget -y 0x20 0x12 0xfd'], stdout=pipe, stderr=pipe, shell=true) output, code = process.communicate() # stuff output... 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -