Script error

Discussions, Bug Reports and Issues related to Beta versions of SharpCap
Post Reply
astfu
Posts: 12
Joined: Sun Feb 14, 2021 12:04 pm

Script error

#1

Post by astfu »

Hello,

in Version 3.3.7313 (64Bit) following script is not working:

Time_List = [SharpCap.SelectedCamera.Controls[17].Value]

-->Traceback (most recent call last):
File "<string>", line 15, in <module>
TypeError: 'Controls' object is not subscriptable

In Version 3.2 it's working.

Best regards

Sven
User avatar
admin
Site Admin
Posts: 13296
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Script error

#2

Post by admin »

Hi Sven,

I found some error cases when testing that cause problems due to the contents of the control list being changed while the software was looking for a particular control. To avoid that being a problem in future I ended up removing the ability to access the controls by index. It's probably a bad practice anyway since the index number may change in different versions of SharpCap as new features are added.

Please try using

Controls.FindByName('name')
Controls.FindById(id)
Controls.Find(lambda x: .....)

These are all implemented in a way that is safe against problems caused by the list of controls changing.

cheers,

Robin
astfu
Posts: 12
Joined: Sun Feb 14, 2021 12:04 pm

Re: Script error

#3

Post by astfu »

Hi Robin,

have a example? I'm a newcomer with Python.
I can read the Exposuretime now: SharpCap.SelectedCamera.Controls.Exposure.Value
but how I can read (or write) the start (end) calibration?

thanks! Sven
User avatar
admin
Site Admin
Posts: 13296
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Script error

#4

Post by admin »

Hi Sven,

Code: Select all

print SharpCap.SelectedCamera.Controls.FindByName('Calibration Start Pos Adjust').Value
SharpCap.SelectedCamera.Controls.FindByName('Calibration Start Pos Adjust').Value = 1234
cheers,

Robin
astfu
Posts: 12
Joined: Sun Feb 14, 2021 12:04 pm

Re: Script error

#5

Post by astfu »

Hi Robin,

thanks, now I understand this.

cheers Sven
Post Reply