Creating custom notifications?

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
rl_kabi
Posts: 7
Joined: Fri Jul 28, 2023 10:41 pm

Creating custom notifications?

#1

Post 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
User avatar
admin
Site Admin
Posts: 13362
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Creating custom notifications?

#2

Post 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
rl_kabi
Posts: 7
Joined: Fri Jul 28, 2023 10:41 pm

Re: Creating custom notifications?

#3

Post 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
User avatar
admin
Site Admin
Posts: 13362
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Creating custom notifications?

#4

Post 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
Post Reply