I currently have a restaurant simulation program, GUI by Tkinter and I was finding a way to allow multiple instantiation of the programs to interact with one another in the sense of updating its key variables. (Sorry for my poor English)
Let's say:
- Five Users have opened this program at the same time using same PC. (Hypothetical)
- There are three functions in the program, namely
Order
,See Inventory
,andSee Sales
- Assume that all five have made an order
Now, the restaurant must keep track of the orders made, and the inventory to cook the food.
I tried coding the program by using txt
file import and export to keep track of the data but it was just now that I realized the txt
file can be edited by programs ONE AT THE TIME. (Cannot edit single txt
file at once)
Q: What is the better approach in saving the values of the variables used in the program so that multiple users can use the program with real-time updated values of the variables?
- Someone told me that I could try using
Global
variables. But how could I possible assign values to them and keep them updated? (Local variables get initialized everytime when the program ran)
Thank you for reading my Question!