I am trying to create a GUI in tkinter. The Gui is basically for Mcp23017. I am trying to configure the input and output pins so that the user could change them according to their choice.. There is also an option to make the inputs/outputs high or low..
Now I am trying to read a pin using 'i2cget'(using a seperate function).. I need to display the output of this subprocess call into a label on the gui..
This is what my 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 this function excutes(by pressing a button), however it prints a value '1' on the python shell alternatly when I press the button... I dont know how to redirect the output to the label.. Could somebody suggest something?
Update:: On executing the suggested commands:
process = subprocess.Popen(['i2cget -y 0x20 0x12 0xFD'], stdout=PIPE, stderr=PIPE, shell=True)
output, code = process.communicate()
I printed the 'output' and 'process' and they gave me the follwing respectivley:
b'' <subprocess.Popen object at 0x00000000035CB2B0>
Since nothing is connected to the pin I expect it to return a value of '0'.. I don't know what is the b'' it is giving me ...
Any advice is really appreciated..
Kind Regards, Namita.