omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. cvp
    3. Posts

    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.


    • Profile
    • Following 0
    • Followers 42
    • Topics 134
    • Posts 6446
    • Best 642
    • Controversial 0
    • Groups 0

    Posts made by cvp

    • RE: PyKeys

      @ihf perhaps we could try to solve your problem with calculate.py
      This one surely does not need a lot of memory
      What happens if you select it as keyboard?
      Do you get this

      alt text

      for me, on my iPad with beta.
      I did not install beta on my iPhone, thus no test possible.

      posted in Pythonista
      cvp
      cvp
    • RE: PyKeys

      @ihf Sincerely, I don't know and, even, I have doubts. But I can't help more for this problem. Hoping that next beta will solve these keyboards problems. I can't believe these keyboards examples are vital for you.

      posted in Pythonista
      cvp
      cvp
    • RE: Resize Image with Pillow and the right orientation

      @kami said

      problem with the orientation

      What is the problem?
      Do you mean that you turned your camera before taking the photo?

      Kind of problems

      alt text

      Flag is orientation flag in exifs of the photo

      Anyway, your "data" is a PIL.Image and can be rotated (before resizing) with data.rotate(...), see Pythonista doc.

      And use this kind of code to get this flag

      import photos
      assets = photos.get_assets()
      asset = photos.pick_asset(assets=assets)
      pil = asset.get_image()
      pil.show()
      exifs = pil.getexif()
      orientation = exifs[274]
      print(orientation)
      if orientation == 6:
      	pil = pil.rotate(90)
      pil.show()	
      
      posted in Pythonista
      cvp
      cvp
    • RE: How to get gyroscope data in pythonista?

      @WoodBridge please read Apple doc here CMMotionManager

      posted in Pythonista
      cvp
      cvp
    • RE: How to get gyroscope data in pythonista?

      @WoodBridge in the code, you find these lines and CMMotionManager.gyroData()

      		# https://forum.omz-software.com/topic/3030
      		CMMotionManager = ObjCClass('CMMotionManager').alloc().init()
      		#print(CMMotionManager.isDeviceMotionAvailable())
      		CMMotionManager.startGyroUpdates()
      		while True:
      			# EulerAngles is a SCNVector3
      			# The order of components in this vector matches the axes of rotation:
      			# Pitch (the x component) is the rotation about the node’s x-axis.
      			# Yaw (the y component) is the rotation about the node’s y-axis.
      			# Roll (the z component) is the rotation about the node’s z-axis.
      			#pitch += (random() - 0.5) * delta_ang
      			#yaw   += (random() - 0.5) * delta_ang
      			#roll  += (random() - 0.5) * delta_ang
      			gyro_data = CMMotionManager.gyroData()
      			if not gyro_data:
      				#print('data not available (yet?)')
      				continue
      			# Using the custom struct here:
      			rate = gyro_data.rotationRate(argtypes=[], restype=self.CMRotationRate)
      			# You can now access the struct's fields as x, y, z:
      			roll  = rate.z
      			pitch = rate.x
      			yaw   = rate.y
      			#print(rate.x, rate.y, rate.z)
      
      posted in Pythonista
      cvp
      cvp
    • RE: How to get gyroscope data in pythonista?

      @WoodBridge The Pythonista motion module only gives a part of the gyroscopic data.
      But iOS ObjectiveC CMMotionManager class gives full gyroscopic data.
      Could you try this little script which allows you to select a photo in your camera roll and displays it as a 3D box that you can rotate in all directions with your finger. Check the code and you will see how to get rotation rate from gyroscopic data.

      code is here

      posted in Pythonista
      cvp
      cvp
    • RE: Error during connection via Paramiko in Pythonista beta 340008

      @tanjiro887 thanks to try to help me but your code is C-code and under Pythonista we only can program in Python. I guess that your advice could be good for @omz who develops Pythonista in C, but I also guess he is aware of the problem and I'm confident he will solve it in next beta/version.
      Anyway, welcome in this forum

      posted in Pythonista
      cvp
      cvp
    • Error during connection via Paramiko in Pythonista beta 340008

      Error is

      Unknown exception: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
      Traceback (most recent call last):
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 1799, in run
          self.kex_engine.parse_next(ptype, m)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/kex_group1.py", line 76, in parse_next
          return self._parse_kexdh_reply(m)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/kex_group1.py", line 113, in _parse_kexdh_reply
          self.transport._activate_outbound()
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 2136, in _activate_outbound
          engine = self._get_cipher(self.local_cipher, key_out, IV_out)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/paramiko/transport.py", line 1667, in _get_cipher
          return self._cipher_info[name]['class'].new(key, self._cipher_info[name]['mode'], '', counter)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/Crypto/Cipher/AES.py", line 96, in new
          return AESCipher(key, *args, **kwargs)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/Crypto/Cipher/AES.py", line 60, in __init__
          blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/Crypto/Cipher/blockalgo.py", line 142, in __init__
          self._cipher = factory.new(key, *args, **kwargs)
      SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
      
      --- error during connection to: iMac : PY_SSIZE_T_CLEAN macro must be defined for '#' formats
      
      posted in Pythonista
      cvp
      cvp
    • RE: Google Drive connection falls in error in Pythonista beta: needs a temporary workaround

      @omz same problem with MutableMapping

      Thanks to @ccc, this also works

      setattr(collections, "MutableMapping", collections.abc.MutableMapping)
      
      posted in Pythonista
      cvp
      cvp
    • RE: Google Drive connection falls in error in Pythonista beta: needs a temporary workaround

      @ccc Thanks. It seems to work, my program crashes further, then I've still to search...
      I add you in my guru's list (note that you were already first in the list for Python 😉 but I didn't even know that Python allows such bypass).

      posted in Pythonista
      cvp
      cvp
    • RE: Google Drive connection falls in error in Pythonista beta: needs a temporary workaround

      @ccc I know but I can't change Pythonista code it-self thus I hope a kind of swizzle.

      posted in Pythonista
      cvp
      cvp
    • Google Drive connection falls in error in Pythonista beta: needs a temporary workaround

      To @omz, @JonB or other guru: the Google Drive connection falls in error in Pythonista beta, due to an identified error in Pythonista code.
      Could one of you provide a temporary workaround, like using swizzle, because it is very annoying for my regular processes.
      Thanks a lot in advance

      PS paid by a beer at next meeting 😀

      Traceback (most recent call last):
        File "/private/var/mobile/Containers/Shared/AppGroup/94C45A26-1F47-4486-9539-896F8F44AA91/Pythonista3/Documents/site-packages/GoogleDriveBrowser.py", line 347, in <module>
          main()
        File "/private/var/mobile/Containers/Shared/AppGroup/94C45A26-1F47-4486-9539-896F8F44AA91/Pythonista3/Documents/site-packages/GoogleDriveBrowser.py", line 300, in main
          gauth = GoogleAuth(google_drive_auth_path)
        File "/private/var/mobile/Containers/Shared/AppGroup/94C45A26-1F47-4486-9539-896F8F44AA91/Pythonista3/Documents/site-packages/pydrive/auth.py", line 169, in __init__
          self.settings = LoadSettingsFile(settings_file)
        File "/private/var/mobile/Containers/Shared/AppGroup/94C45A26-1F47-4486-9539-896F8F44AA91/Pythonista3/Documents/site-packages/pydrive/settings.py", line 143, in LoadSettingsFile
          data = load(stream, Loader=Loader)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/__init__.py", line 73, in load
          return loader.get_single_data()
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 38, in get_single_data
          return self.construct_document(node)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 47, in construct_document
          for dummy in generator:
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 399, in construct_yaml_map
          value = self.construct_mapping(node)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 205, in construct_mapping
          return super().construct_mapping(node, deep=deep)
        File "/var/containers/Bundle/Application/42AA46AA-4145-4FC9-8A31-7063E5F0ADE2/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/yaml/constructor.py", line 127, in construct_mapping
          if not isinstance(key, collections.Hashable):
      AttributeError: module 'collections' has no attribute 'Hashable'
      
      posted in Pythonista
      cvp
      cvp
    • RE: Photo album slideshow

      @mestela It would be better to use ui.animate for your alpha animation, but it is not interruptible, "as is"

      But thanks to ObjectiveC, you can cancel a view animation, knowing that, doing so, goes directly at end of the animation. Not sure that I'm clear enough, thus this little example to show effect.
      Without canceling the animation, the ImageView see its alpha going from 0 to 1 in 10 seconds.
      Pressing the stop animation button, directly goes to alpha = 1

      import ui
      from objc_util import *
      
      v = ui.View(background_color='white')
      v.frame = (0,0,400,400)
      
      iv = ui.ImageView()
      iv.frame = (10,10,300,300)
      iv.image = ui.Image.named('test:Lenna')
      iv.alpha = 0
      v.add_subview(iv)
      
      bstop = ui.Button(title='stop\nanimation')
      bstop.border_width = 1
      bstop.border_color ='blue'
      bstop.corner_radius = 10
      # display button title in multiple lines
      bo = bstop.objc_instance
      for sv in bo.subviews():
      	if hasattr(sv,'titleLabel'):
      		tl = sv.titleLabel()
      		tl.numberOfLines = 0
      		break
      bstop.frame = (310,10,80,50)
      def stopanim(sender):
      	iv.objc_instance.layer().removeAllAnimations()
      bstop.action = stopanim
      v.add_subview(bstop)
      
      v.present('sheet')
      
      def animation():
          iv.alpha = 1.0 # fade in
      ui.animate(animation, duration=10.0)
      
      posted in Pythonista
      cvp
      cvp
    • RE: Photo album slideshow

      @mestela and even do the rotate in your reset_timer() method, passing the rotate argument

      	def reset_timer(self,rot):
      		self.assets.rotate(rot)
                      .
      
      def swipe_left(data):
      	#v.assets.rotate(-1)
      	#v.asset = v.assets[0]
      	v.reset_timer(-1)    <------------
      	#v.set_needs_display()
      
      posted in Pythonista
      cvp
      cvp
    • RE: Photo album slideshow

      @mestela you can move two lines in your reset_timer() method

      	def reset_timer(self):
      		self.asset = v.assets[0]             # <-------
      		self.start_time = time.time()
      		self.current_time = self.start_time
      		self.end_time = self.start_time + self.hold_time
      		self.set_needs_display()           # <-------
      
      def swipe_left(data):
      	v.assets.rotate(-1)
      	#v.asset = v.assets[0]
      	v.reset_timer()
      	#v.set_needs_display()
      
      def swipe_right(data):
      	v.assets.rotate(1)
      	#v.asset = v.assets[0]
      	v.reset_timer()
      	#v.set_needs_display()
      .
      .
      .
      while 1:
              .
              .
      	v.assets.rotate(-1)
      	#v.asset = v.assets[0]
      	v.reset_timer()
      	#v.set_needs_display()
      
      posted in Pythonista
      cvp
      cvp
    • RE: How to scan wifi network

      @ccc I use fing for years but, as I know, only Apple Airport app gives signals strength

      alt text

      posted in Pythonista
      cvp
      cvp
    • RE: How to scan wifi network

      @Gfox79 I think it is possible to get SSID but not signal strength. In the past, I had a small script using CNCopyCurrentNetworkInfo function but this one has been deprecated after iOS 14.

      posted in Pythonista
      cvp
      cvp
    • RE: How to scan wifi network

      @Gfox79 I don't think it is possible via Pythonista, hoping I'm wrong and that somebody else could give a better answer

      posted in Pythonista
      cvp
      cvp
    • RE: How to scan wifi network

      @Gfox79 Apple AirPort free app

      posted in Pythonista
      cvp
      cvp