Page 1 of 1

Running script from toolbar

Posted: Tue Jul 18, 2017 2:34 am
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.

Re: Running script from toolbar

Posted: Tue Jul 18, 2017 4:35 pm
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

Re: Running script from toolbar

Posted: Tue Jul 18, 2017 5:33 pm
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.