-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdevice-list-changed.py
More file actions
32 lines (20 loc) · 913 Bytes
/
device-list-changed.py
File metadata and controls
32 lines (20 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import imagingcontrol4 as ic4
def handle_device_list_changed(device_enum: ic4.DeviceEnum):
print("Device list changed!")
print(f"Found {len(ic4.DeviceEnum.devices())} devices")
print(ic4.DeviceEnum.devices())
def example_device_list_changed():
enumerator = ic4.DeviceEnum()
token = enumerator.event_add_device_list_changed(handle_device_list_changed)
print("Waiting for DeviceListChanged event")
print("Press Enter to exit")
input()
# Technically, this is not necessary, because the enumerator object is deleted when the function is exited
# But for demonstration purposes, the event handler is removed:
enumerator.event_remove_device_list_changed(token)
if __name__ == "__main__":
ic4.Library.init(api_log_level=ic4.LogLevel.INFO, log_targets=ic4.LogTarget.STDERR)
try:
example_device_list_changed()
finally:
ic4.Library.exit()