Re: How to properly set aperture, iso and shutterspeed?

Jim Easterbrook <[email protected]> Tue, 20 Oct 2020 16:28:15 +0100
Newsgroups gmane.comp.multimedia.gphoto.user
Message-ID <[email protected]>
On 20/10/2020 15:33, Jochen Keil wrote:
> 
> My idea was to get a list of choices (get_choices()), look up the index 
> of the current value, increase the index by one, look up the new value 
> and set it. This works reasonably well for iso values.

For those not familiar with the Python interface, 
gp_widget_get_choices() and CameraWidget.get_choices() simply call 
gp_widget_get_choice() repeatedly for each possible choice number and 
make a list of the corresponding string values.

> However, there are some oddities when it comes to f-number and shutterspeed:
> 
> For example when the current shutterspeed is above 1/3, `get_value` will 
> return fractions of 10, e.g. 4/10, 10/10, etc. However, the list 
> returned by get_choices contains the value '1' instead of '10/10' hence 
> the lookup fails.

The Python version of gp_widget_get_choice() always returns a string, 
but gp_widget_get_value() returns different types according to the 
widget type:
GP_WIDGET_MENU, GP_WIDGET_TEXT, GP_WIDGET_RADIO -> string
GP_WIDGET_RANGE -> float
GP_WIDGET_DATE, GP_WIDGET_TOGGLE -> integer

I assume you are getting the string '1' rather than the integer 1, in 
which case there appears to be a discrepancy between the C functions 
gp_widget_get_choice() and gp_widget_get_value().

> Is there an easy way to set shutterspeed and f-number to the next value 
> or do I have to somehow figure out what 10/10 means and translate it to 
> 1? I think I could use a static table for that but that seems to be 
> laborious and error-prone.

The Python Fraction type is probably the easiest way to convert the 
strings '10/10' and '1' to the same result.
-- 
Jim Easterbrook                 <http://www.jim-easterbrook.me.uk/>