Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

how to get value from _winrt._winrt_base object #22

Answered by dlech
kfal asked this question in Q&A
Discussion options

You must be logged in to vote

Python tip: you can use Python subscript expression instead of calling lookup on a IMapView:

lux.properties["{C458F8A7-4AE8-4777-9607-2E9BDD65110A} 62"]

Since this returns a generic WinRT object type (equivalent of .NET System.Object), you probably need to use the IPropertyValue APIs to get the value. See https://github.com/pywinrt/pywinrt/blob/main/test/test_property_value.py for extensive examples.

Maybe something like this?

import winsdk.windows.devices.sensors as ds
import winsdk.windows.foundation as wf

als = ds.LightSensor.get_default()
lux = als.get_current_reading()
p_x = lux.properties["{C458F8A7-4AE8-4777-9607-2E9BDD65110A} 62"]
x = wf.IPropertyValue._from(p_x).get_single()
print(

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dlech
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants