Enable / Disable custom buttons?

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

Enable / Disable custom buttons?

Post by BillC2018 » Sat Apr 28, 2018 12:39 am

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: 3094
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Enable / Disable custom buttons?

Post by admin » Sat Apr 28, 2018 9:58 am

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: 3094
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Enable / Disable custom buttons?

Post by admin » Sun Apr 29, 2018 9:06 pm

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: 6
Joined: Fri Apr 27, 2018 6:39 pm

Re: Enable / Disable custom buttons?

Post by BillC2018 » Wed May 02, 2018 11:49 pm

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: 62
Joined: Tue Nov 14, 2017 9:49 pm

Re: Enable / Disable custom buttons?

Post by 1CM69 » Thu Aug 30, 2018 5:38 pm

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: 3094
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Enable / Disable custom buttons?

Post by admin » 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

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

Re: Enable / Disable custom buttons?

Post by 1CM69 » Thu Aug 30, 2018 9:43 pm

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

Who is online

Users browsing this forum: No registered users and 1 guest