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?
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Posts made by mikeno
-
RE: Not sure how to combine ui with a plot
-
RE: Not sure how to combine ui with a plot
Hi, this is OK but the black circle is over the red one, how can we put the black circle behind as background?
-
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
Hi everybody, thx for helping, I’ll buy Pyto and try.
-
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
Thx for trying, I’ll wait!
-
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
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)
-
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
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?
-
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
I don’t know PyTo but I will try, thx in any case
-
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
@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
-
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
Yes, it works but only if the iPad is awake
-
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
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. -
RE: Correct way to call Pythonista script from within a Shortcuts workflow?
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 -
RE: draw ui.Path within the coordinate system of a node
Thx cvp but I don’t know how to download a module into Pythonista
-
RE: draw ui.Path within the coordinate system of a node
Whao, I’m impressed, thank you!
But I don’t understand why it doesn’t work in my last example -
RE: draw ui.Path within the coordinate system of a node
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?
-
RE: draw ui.Path within the coordinate system of a node
Thx to both of you, concerning the gestures, it seems to be a little bit complicated but I will try
-
RE: draw ui.Path within the coordinate system of a node
... 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
-
RE: draw ui.Path within the coordinate system of a node
Yes thx it works but it doesn’t with several polygons
-
RE: draw ui.Path within the coordinate system of a node
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
-
RE: draw ui.Path within the coordinate system of a node
Hi Mikael, thx for replying but is there a way to avoid this?