Enable / Disable custom buttons?

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
BillC2018
Posts: 7
Joined: Fri Apr 27, 2018 6:39 pm

Enable / Disable custom buttons?

#1

Post by BillC2018 »

I have been working on a dithering script, and I add a start and stop custom button to the toolbar when the script is loaded to start an image capture sequence with dithering, and was wondering if there was a way to disable the buttons . IE . disable the start button if its running , disable the stop button if its not .. that kind of thing.

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

Re: Enable / Disable custom buttons?

#2

Post by admin »

Hi,

the answer is no sadly, but it's a good idea - hopefully not too hard for me to add in a future version.

cheers,

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

Re: Enable / Disable custom buttons?

#3

Post by admin »

Yes, it was nice and easy, so it is in 3.1.5164. There is now an 'Enabled' property on the CustomButton object which you can set to false to disable the button.

cheers,

Robin
BillC2018
Posts: 7
Joined: Fri Apr 27, 2018 6:39 pm

Re: Enable / Disable custom buttons?

#4

Post by BillC2018 »

Cool!
Thanks so much, will have to download the latest and give it a shot. I finally figured out how I needed to massage the "characters" so I could send binary data out a python socket. Must be a limit of IronPython but this works in straight python but failed from within the sharpcap scripting environment.

cmd = bytearray()
cmd.append(4)
socket.send(cmd)

anyways thanks for the quick work!

Bill
User avatar
1CM69
Posts: 63
Joined: Tue Nov 14, 2017 9:49 pm

Re: Enable / Disable custom buttons?

#5

Post by 1CM69 »

Hi,

just wondering how the Disable of custom buttons is expressed.

I have tried:

Code: Select all

SharpCap.CustomButtons.Enabled = False

Code: Select all

SharpCap.CustomButtons('My Script Name').Enabled = False
but both throw errors

Cheers..,

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

Re: Enable / Disable custom buttons?

#6

Post by admin »

Hi,

works for me with a quick test in the script console :

Code: Select all

cb1 = SharpCap.AddCustomButton("Test", None, None, None)
cb1.Enabled = False
What error do you get? Are you trying to set the Enabled flag from a different thread perhaps? If so, maybe

Code: Select all

def disableButton:
	button.Enabled = False

SharpCap.MainWindow.RunInUIThread(disableButton)
will work as a workaround.

cheers,

Robin
User avatar
1CM69
Posts: 63
Joined: Tue Nov 14, 2017 9:49 pm

Re: Enable / Disable custom buttons?

#7

Post by 1CM69 »

admin wrote: Thu Aug 30, 2018 7:59 pm Hi,

works for me with a quick test in the script console :

Code: Select all

cb1 = SharpCap.AddCustomButton("Test", None, None, None)
cb1.Enabled = False
What error do you get? Are you trying to set the Enabled flag from a different thread perhaps? If so, maybe

Code: Select all

def disableButton:
	button.Enabled = False

SharpCap.MainWindow.RunInUIThread(disableButton)
will work as a workaround.

cheers,

Robin
The

Code: Select all

cb1 = 
is what I was missing, I just had the plain button creation code.

Cheers..,

Kirk
Post Reply