Page 1 of 1

Enable / Disable custom buttons?

Posted: Sat Apr 28, 2018 12:39 am
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!

Re: Enable / Disable custom buttons?

Posted: Sat Apr 28, 2018 9:58 am
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

Re: Enable / Disable custom buttons?

Posted: Sun Apr 29, 2018 9:06 pm
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

Re: Enable / Disable custom buttons?

Posted: Wed May 02, 2018 11:49 pm
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

Re: Enable / Disable custom buttons?

Posted: Thu Aug 30, 2018 5:38 pm
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

Re: Enable / Disable custom buttons?

Posted: Thu Aug 30, 2018 7:59 pm
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

Re: Enable / Disable custom buttons?

Posted: Thu Aug 30, 2018 9:43 pm
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