qpython-android / qpython

QPython is an Android Python engine primarily designed for Python and AI learners. It offers a range of impressive features to enhance Python programming experience.
https://www.qpython.org
1.03k stars 191 forks source link

how to turn on the phone flashlight with qpython ? #198

Closed florianpetiot closed 2 years ago

florianpetiot commented 2 years ago

I coded a Python program to make time laps with the Androidhelper library, only I have one last problem: turn on the light of the phone when it is dark

I have searched the documentation of Androidhelper but it seems to me that you can't control the light with it

Do you have a solution? Can you help me?

guangrei commented 2 years ago

try use plyer

from plyer import flash

flash.on()
flash.off()

if you got error cant import flash, you have to upgrade it with pip3 install plyer --upgrade

florianpetiot commented 2 years ago

Thank you for solving my problem!

Since September I have already used my program, it was to do a school experiment on the Physarum Polycephalum (Blob). It moves better if it's dark but we put a small light next to it Here is the result: https://youtu.be/tNQYsPXUFcY