I work with Raspberry Pi. I wrote a program for displaying a list of files on a text screen and paging it with clock buttons. I connected my program to the program Pronterface. Pronterface starts up, during the work it calls my program, my program writes the name of the selected file to a variable, Pronterface gets this variable and works with it. In the trial version, the value of this variable is written to the txt file.
A piece of code for my program (program.py)
............... if GPIO.input(16) == False: tex=images[i] tex=str(tex) GPIO.cleanup() exit() ...........
A piece of Pronterface code:
import program ...... program.main() .... def getText(): return program.tex .... zz=getText() my=open("File.txt", "w") my.write(zz) my.close()
After clicking on the button hanging on the GPIO16, everything closes. And if you remove exit (), then nothing happens - Pronterface loading is in the same place where my program was called
Just in case, I post the full code of my program and Pronterface below. http://rghost.ru/64bHTWYxj
globals tex
. And is it so important to store the variable? Maybe it's better to stir up the function, which will return the value and pull the function? - gil9red