I'm currently working to modify some python code to make it do what I want, but I keep running into the same problem.
The python code gets Entities from a JSON file. I have edited that JSON file to add values, & I have successfully added them to the python script. using those entities however has been a problem. My biggest issue is that I keep needing to pass arguments to an application but I need 2 values to be delivered as a single value.
{
"maxWidth": "900",
"maxHeight": "1100",
"qualityNum": "90"
}
in the python script it gets the values with a
maxWidth = prefs.get('maxWidth', '600')
maxHeight = prefs.get('maxHeight', '600')
but then when the script is run it needs to pass them as a single value maxWidth
xmaxHeight
or 900x1100
from my example.
it then assembles the args
args = [path, 'mogrify','-resize', maxWidth, '-quality', qualityNum, '-path', temp_dir, original_img_path]
I have tried & failed in the args assembly to mux them together, but it doesn't seem to be possible at that stage. So I thought the best thing to do is create a new entity maxSize
& have that be a mix of the 2 with an x
between them.
Unfortunately everything I have tried gives a syntax error.
Is there a way, in python, to create an entity value, or any other value I could use, that is made up of the text of 2 entities with manually entered text between them?
You can use f-string formatting:
combined = f"{maxWidth}x{maxHeight}"
Or if using the dictionary:
combined = f"{dict_name['maxWidth']}x{dict_name['maxHeight']}"