Page 1 of 1

Creating custom notifications?

Posted: Mon Sep 04, 2023 7:46 am
by rl_kabi
Hi,

I was wondering if it is possible to make it so that I can have my own notifications pop up after specific things are completed within my script?Notifications being like the ones that pop up in the process of a plate solve, such as "Snapshot captured to...", "Solving frame... Please wait...", "Plate solve succeeded, currently pointing at [coordinates]" et cetera.

Cheers,

RL

Re: Creating custom notifications?

Posted: Mon Sep 04, 2023 1:09 pm
by admin
Hi,

yes, you can do that

Code: Select all

from SharpCap.Base import NotificationStatus
SharpCap.ShowNotification("Hello", NotificationStatus.Error)
You also have 'OK' and 'Warning' as possible status levels, giving you the orange/green/yellow notifications.

cheers,

Robin

Re: Creating custom notifications?

Posted: Mon Sep 04, 2023 5:26 pm
by rl_kabi
Hi Robin,

I see, thank you!

Is it also possible to create some kind of custom button that can terminate the running script? Mainly asking because ideally, for a script I'm working on, a user can run the script without having to open the console (and possibly be intimidated by the interface if they don't have much experience with programming).

Cheers,

RL

Re: Creating custom notifications?

Posted: Mon Sep 04, 2023 7:18 pm
by admin
Hi,

yes, you can do that

Code: Select all

# IronPython Pad. Write code snippets here and F5 to run. If code is selected, only selection is run.
from SharpCap.Base import NotificationButton
from SharpCap.Base import NotificationStatus
def Test():
 	print ("hello")
b = NotificationButton("Test Button", Test)
SharpCap.ShowNotification("Press the button", NotificationStatus.OK, False, 30, None, b)
'help(...)' is your friend by the way...

Code: Select all

help (SharpCap.ShowNotification)
Help on built-in function ShowNotification:

ShowNotification(...) method of builtins.Application instance
    ShowNotification(self: Application, notificationMessage: NotificationMessage)ShowNotification(self: Application, messageText: str, status: NotificationStatus, showCloseBox: bool, visibleForSeconds: Int32, closedCallback: Action, button1: NotificationButton, button2: NotificationButton)

Code: Select all

help (NotificationButton)
Help on class NotificationButton in module builtins:

class NotificationButton(object)
 |  NotificationButton(buttonText: str, buttonPress: Action)
 |  
 |  Methods defined here:
 |  
 |  __new__(...)
 |      __new__(cls: type, buttonText: str, buttonPress: Action)
 |  
 |  __repr__(...)
 |      __repr__(self: object) -> str
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  ButtonPress
 |      Get: ButtonPress(self: NotificationButton) -> Action
 |  
 |  ButtonText
 |      Get: ButtonText(self: NotificationButton) -> str
The only thing it doesn't tell you is exactly where to import types from , but SharpCap.Base or SharpCap.Interfaces are usually a good bet.

cheers,

Robin