There is a program for interacting with a 3d-printer. I screwed a module to it that allows you to work with a text display, a clock with buttons and a flash drive. The program starts, then the module automatically starts, which reads the files from the flash drive and displays them in a list. The list is scrolled with clock buttons and then the name of the selected file in the variable is transferred to the main program from the module. The program prints this file and you need to display the percentage of printing on the display. To display the printing process in% in the program there is a separate variable. But if I call the module again, the main program will pause until the module closes again. How to transfer variable value to module in real time mode without crutches?

At the moment I am passing the file name like this: Now everything looks like this for me: Program 1:

... import program ... filename=program.main() ... 

Program 2:

 ... global fname fname="file_name" return fname ... 
  • The question is unclear. What do you mean by "call module"? You can call a function, but load / import a module, or execute the module as a script ( __name__=='__main__ ). Perhaps you are trying to organize a program so that it can do several things at the same time — network code and GUI code often use cooperative multitasking — a vivid example of JavaScript (all events in one thread occur alternating) and only selected things are executed in the background thread / process pool ( which in principle can work in parallel). - jfs

0