How/where to store calibration values - written by program A, read by program B
Greg Walters
greg.gregwa at gmail.com
Thu Dec 28 13:03:03 EST 2023
First, one of the posters got it right. Nothing is REALLY ever "written"
to the file. Consider it a global variable that isn't a global variable.
Assume you have two modules, A and B. Both modules import config.
Furthermore, let's assume that Module B 'writes' a variable called "font"...
shared.font="TkDefaultFont"
That information is immediately available to Module A. All Module A has to
do is (assuming that it has been initialized previously) do something like
this...
myFont=shared.font
Now, myFont has the value "TkDefaultFont" in both modules A and B.
Further, let's assume that we need to pass a ttk::Theme to Module B...
Module A does a
shared.currentTheme = "clam"
Anytime Module B wants to check the value of the shared variable, it can
do...
MyCurrentTheme = shared.currentTheme.
You can also use a similar variable that will hold a flag boolean "saying"
something like
shared.UpdatedInfo = True
This can be tested at any time via any timer check, including a Tkinter
root.after type timer. If the timer is true, simply go through your list
of shared variables (You should keep them in a list just to be sure) then
they can be checked on a timed basis. Or just use ...
MyVariable=shared.VariableName anytime you need to make sure it's updated.
If the value is the same, it only wastes a few clock cycles. However if it
has been updated, then you got the latest version.
This can work for any number of modules. You aren't limited to just two.
I hope this helps.
Greg
--
*My memory check bounced*
Greg Walters
More information about the Python-list
mailing list