How/where to store calibration values - written by program A, read by program B

2023-12-27 Thread Greg Walters via Python-list
Many years ago, Fredrik Lundh provided an answer for this question
on his website effbot.org.  Unfortunately that site has gone, but luckily,
it has been preserved in the "wayback machine"...

https://web.archive.org/web/20200724053442/http://effbot.org:80/pyfaq/how-do-i-share-global-variables-across-modules.htm

In short, create an empty file named something like 'config.py' or
'shared.py' in a folder that both scripts can use.
Import the file in both scripts.

import shared

Then when you want to share a value, use...

shared.variablename=3.14159

The file can then be accessed by both scripts.

The biggest caveat is that the shared variable MUST exist before it can be
examined or used (not surprising).

I sincerely hope this helps.

Greg
-- 
*My memory check bounced*



Greg Walters
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How/where to store calibration values - written by program A, read by program B

2023-12-28 Thread Greg Walters via Python-list
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
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Subject: Are there any easy-to-use Visual Studio C# WinForms-like GUI designers in the Python world for Tk?

2023-12-29 Thread Greg Walters via Python-list
> I'm used to C# WinForms, which has an easy-to-use drag-and-drop
GUI designer in Visual Studio. Is there anything similar for Tk? How
about Qt? What do you recommend as the easiest way to create GUI programs
in Python, similar to the ease of use of C# WinForms?

I can't say much for Qt other than there is a GUI designer for it, but I
don't know much about it.

As to the portion of your question about Python and Tkinter, YES!
The project is called PAGE and it is a drag and drop designer using the Tk
and ttk toolkits (basically Tkinter).

It's been around for many years, is completely FREE and open source, the
source code is included and works on Windows, Linux and Mac OS.

The current version is 7.6 and you can find it at
https://sourceforge.net/projects/page/ and it has been downloaded over 2000
times just in December, and over 26,000 times in 2023.

There is a TONNE of examples, full documentation and a number of
tutorials.  The Sourceforge acts as the main help site, but there is also a
Discord site dedicated to help and support.

I sincerely hope this helps!

Greg Walters


-- 
*My memory check bounced*



Greg Walters
-- 
https://mail.python.org/mailman/listinfo/python-list