Running script from toolbar

A place to report problems and bugs in SharpCap
Forum rules


If you have a problem or question, please check the FAQ to see if it already has an answer : https://www.sharpcap.co.uk/sharpcap-faqs

Please also read about Troubleshooting USB Issues before posting.

*** Please do not post license keys - please report any problems with licensing to 'admin' by private message ***

Please include the following details in any bug report:

* Version of SharpCap
* Camera and other hardware being user
* Operating system version
* Contents of the SharpCap log after the problem has occurred.
[If SharpCap crashes, please send the bug report when prompted instead of including the log]
Post Reply
User avatar
oopfan
Posts: 1327
Joined: Sat Jul 08, 2017 2:37 pm
Location: New York
Contact:

Running script from toolbar

#1

Post by oopfan »

SharpCap 3.0.4002.0

1. Create foo.py and save to desktop:

Code: Select all

# foo.py
def foo():
    print SharpCap.Cameras
SharpCap.AddCustomButton("foo", None, "foo", foo)
2. Add foo.py to File > SharpCap Settings > Startup Scripts
3. Restart SharpCap
4. Launch Scripting Console
5. Type 'print SharpCap.Cameras' in the immediate execution pane at the ">>>". Notice that it prints the camera list and then gives you ">>>" again.
6. Click "foo" on the toolbar. Now notice that you never get the ">>>" ever, ever again. You need to restart SharpCap.
User avatar
admin
Site Admin
Posts: 13287
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Running script from toolbar

#2

Post by admin »

Workaround:

Press the 'Run' (play) button below the interactive area - this runs the code in the 'Python Pad' at the bottom and brings back the prompt when it has gone missing.

There are other circumstances where the interactive prompt goes missing - unfortunately the IronPythonConsole component I use for the python UI seems to be basically abandoned by the developers now and I would prefer not to spend too much time on understanding and fixing it if I can avoid doing so.

cheers,

Robin
User avatar
oopfan
Posts: 1327
Joined: Sat Jul 08, 2017 2:37 pm
Location: New York
Contact:

Re: Running script from toolbar

#3

Post by oopfan »

Thanks, Robin, that's an acceptable workaround. I can keep "foo" as a registered startup script, and then simply execute foo() from either the Python Pad or from the interactive prompt. I was afraid that I would need to click the "open" toolbar icon and navigate to the python file but now I see that is not necessary.
Post Reply