-
mikeno
You wrote * Another approach would be to have two views that are the same size, that both use draw() -- but only call set_needs_display on the view that needs update. *
Could you please show an example? -
mikeno
Hi, this is OK but the black circle is over the red one, how can we put the black circle behind as background?
-
-
-
mikeno
Thx, the question is now if Pyto can read the barometer sensor value, below a short code which runs fine under Pythonista:
from objc_util import ObjCInstance, ObjCClass, ObjCBlock, c_void_p pressure = None def get_pressure(): def handler(_cmd, _data, _error): global pressure pressure = ObjCInstance(_data).pressure() handler_block = ObjCBlock(handler, restype=None, argtypes=[c_void_p, c_void_p, c_void_p]) CMAltimeter = ObjCClass('CMAltimeter') NSOperationQueue = ObjCClass('NSOperationQueue') if not CMAltimeter.isRelativeAltitudeAvailable(): print('This device has no barometer.') return altimeter = CMAltimeter.new() main_q = NSOperationQueue.mainQueue() altimeter.startRelativeAltitudeUpdatesToQueue_withHandler_(main_q, handler_block) try: while pressure is None: pass finally: altimeter.stopRelativeAltitudeUpdates() #print('Updates stopped.') return pressure.floatValue()*10 pressure = get_pressure() print(pressure)
-
mikeno
I just downloaded it but my trial period already expired because I probably already tried it some times ago and since I don’t know if it works, I don’t want to buy it. If you’ve it, could you try if it runs when iPad is asleep?
-
-
mikeno
@cvp I’m not sure to understand what you mean, but calling a pythonista script from a shortcuts or an automation requires the iPad to be awake
-
-
mikeno
Yes but only everyday, I want to read the value of the barometer sensor every hour, I can get this value with Pythonista. I didn’t find a way to get this information in shortcuts nor in JS (scriptable).
I found also a way to do some tasks every hour in shortcuts but I don’t find a way to get the barometer sensor value. -
mikeno
Hi everybody, I could call a Pythonista script from shortcuts using url and safari but it works only if the iPad is awake, is there a way to let it work when the iPad is asleep?
I also tried running a Pythonista script using scheduler but it works only if I stay in the Pythonista app.
What I want to achieve is writing some info into a file every hour -
-
mikeno
Thx cvp but I don’t know how to download a module into Pythonista
-
mikeno
Whao, I’m impressed, thank you!
But I don’t understand why it doesn’t work in my last example -
mikeno
My last issue is that the drawing doesn’t refresh even when I call explicitly drawTest() as you can see in the example below:
import ui class my(ui.View): def __init__(self, *args, **kwargs): self.factor = .5 def draw(self): print('draw()') self.drawTest() def drawTest(self): print('drawTest()') print('%.1f' % (self.factor)) w,h = ui.get_screen_size() path1 = ui.Path() path1.line_width = 3 ui.set_color('red') path1.move_to(100*self.factor,100*self.factor) path1.line_to(200*self.factor,100*self.factor) path1.line_to(100*self.factor,200*self.factor) path1.close() path1.fill() path2 = ui.Path()#.rect(0,0,w,h) path2.line_width = 3 ui.set_color('blue') path2.move_to(300*self.factor,100*self.factor) path2.line_to(400*self.factor,100*self.factor) path2.line_to(300*self.factor,200*self.factor) path2.close() path2.fill() def touch_began(self, touch): print('touch_began()') self.factor += .5 self.drawTest() def will_close(self): print('will_close()') v = my() v.present('fullscreen',hide_title_bar=True)
It redraws only when I turn the iPad, could you please tell me how I can force the refresh with the right zoom factor?
-
mikeno
Thx to both of you, concerning the gestures, it seems to be a little bit complicated but I will try
-
mikeno
... and then, I need to redraw in order to see the polygons in a different zoom factor. As I wrote, I already tried with ui but I stoped because I could not redraw, that’s why I tried with scene
-
-
mikeno
I just want to draw a filled polygone following numerous coordinates, I already managed to do it with ui and canvas but only scene gives me the possibility to use full screen
-
mikeno
Hi Mikael, thx for replying but is there a way to avoid this?