@@ -26,9 +26,10 @@ def _callback_recieving_fn(self, bridge_port, core_callback):
2626 "org.micromanager.remote.RemoteCoreCallback" , args = (ZMQRemoteMMCoreJ (port = bridge_port ),)
2727 )
2828
29- port = callback_java .get_push_port ()
29+ camel_case = hasattr (callback_java , "getPushPort" )
30+ port = callback_java .getPushPort () if camel_case else callback_java .get_push_port ()
3031 pull_socket = PullSocket (port )
31- callback_java .start_push ()
32+ callback_java .startPush () if camel_case else callback_java . start_push ()
3233
3334 while True :
3435 message = pull_socket .receive (timeout = 100 )
@@ -81,23 +82,26 @@ def __new__(
8182 timeout for underlying bridge
8283 """
8384 try :
84- return JavaObject ("mmcorej.CMMCore" , new_socket = new_socket ,
85+ core = JavaObject ("mmcorej.CMMCore" , new_socket = new_socket ,
8586 port = port , timeout = timeout , convert_camel_case = convert_camel_case , debug = debug )
87+
88+ def register_core_callback_wrapper (callback_fn = None , bridge_port = DEFAULT_BRIDGE_PORT ):
89+ """
90+ Get a CoreCallback function that will fire callback_fn with (name, *args) each
91+ time MMCore emits a callback signal
92+
93+ callback_fn: Callable
94+ a function that takes (name, *args)
95+ bridge_port: int
96+ port of the Core instance to get callbacks from
97+ """
98+ return _CoreCallback (callback_fn = callback_fn , bridge_port = bridge_port )
99+
100+ core .register_core_callback = register_core_callback_wrapper
101+ return core
86102 except Exception as e :
87103 raise Exception (f"Couldn't create Core. Is Micro-Manager running and is the ZMQ server on { port } option enabled?" )
88104
89- def get_core_callback (self , callback_fn = None , bridge_port = DEFAULT_BRIDGE_PORT ):
90- """
91- Get a CoreCallback function that will fire callback_fn with (name, *args) each
92- time MMCore emits a callback signal
93-
94- callback_fn: Callable
95- a function that takes (name, *args)
96- bridge_port: int
97- port of the Core instance to get callbacks from
98- """
99- return _CoreCallback (callback_fn = callback_fn , bridge_port = bridge_port )
100-
101105
102106class Core :
103107 """
0 commit comments