• pulbrich

    It’s a uiView property, supposed to regulate the behavior of a view’s subviews.

    Instance Property
    clipsToBounds
    A Boolean value that determines whether subviews are confined to the bounds of the view.
    

    posted in Pythonista read more
  • pulbrich

    @ProgrammingGo if you ever need to penetrate the domain of various coordinate system representations (angles included) I recommend you look at Pyrr

    posted in Pythonista read more
  • pulbrich

    @cvp you don’t need a separate thread with all the overhead to update the scene objects. There is the scene renderer delegate (can be the same class instance as your main), which has an 'update' method to take care of exactly these type of tasks.

    posted in Pythonista read more
  • pulbrich

    @cvp this is what you meant? 😉

    from objc_util import *
    import ui
    from math import pi
    
    import sceneKit as scn
    
    @on_main_thread
    def demo():
      global bt,i_bt
      main_view = ui.View()
      w, h = ui.get_screen_size()
      main_view.frame = (0,0,w,h)
      main_view.name = 'SceneKit IMU'
      main_view.background_color = 'white'
      
      b = ui.ButtonItem()
      b.title = 'simul bt'
      
      i_bt = 0
      bt = [
                (pi/2,pi/3,pi/4),
                (pi/3,pi/3,pi/4),
                (pi/2,pi/5,pi/4),
                (pi/2,pi/3,pi/8)
                ]
      
      @on_main_thread           
      def b_action(sender):
        global i_bt,bt
        # 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.
        x = bt[i_bt]
        geometry_node.setEulerAngles(x)
        i_bt += 1
        if i_bt == len(bt):
          i_bt = 0
            
      b.action = b_action
      main_view.right_button_items = (b,)
      
      scene_view = scn.View(main_view.frame, superView=main_view)
      scene_view.autoresizingMask = (scn.ViewAutoresizing.FlexibleHeight, scn.ViewAutoresizing.FlexibleRightMargin)
      
      scene_view.allowsCameraControl = True
      
      scene_view.backgroundColor = 'white'
      
      scene = scn.Scene()
      scene_view.scene = scene
        
      root_node = scene.rootNode
      
      camera = scn.Camera()
      camera_node = scn.Node()
      camera_node.camera = camera
      camera_node.position = (-30,30,30)
      root_node.addChildNode(camera_node) 
      
      geometry = scn.Box(10, 10, 10, 0)
       
      geometry_node = scn.Node.nodeWithGeometry(geometry)
      root_node.addChildNode(geometry_node)
      
      Materials = []
      colors = ['red','blue','green','yellow','orange','pink']
      for i in range(0,6):
        Material = scn.Material()
        Material.contents = colors[i]
        Materials.append(Material)
      geometry.materials = Materials
    
      # Add a constraint to the camera to keep it pointing to the target geometry
      constraint = scn.LookAtConstraint.lookAtConstraintWithTarget(geometry_node)
      constraint.gimbalLockEnabled = True
      camera_node.constraints = [constraint]
      
      light_node = scn.Node()
      light_node.position = (30, 0, -30)
      light = scn.Light()
      #light.setType_('spot')
      light.type = scn.LightTypeProbe
      #light.setType_('directional')
      light.castsShadow = True
      light.color = 'white'
      light_node.light = light
      root_node.addChildNode(light_node)
      
      main_view.present('fullscreen')
    
    demo() 
    
    

    posted in Pythonista read more
  • pulbrich

    @cvp said:

    I had remarked similar moustaches but I didn't dare post something

    I guess it just comes with experience.

    posted in Pythonista read more
  • pulbrich

    @pavlinb did you save the above script under the name of pyto.py in Pythonista?

    posted in Pythonista read more
  • pulbrich

    @cvp 😃very creative, best of both worlds... respect!

    posted in Pythonista read more
  • pulbrich

    Or, if readability is not much of a concern:

    dict = {'12345':6, '01928':7}
    list = [1, 2, 3]
    
    found = [k for k in dict.keys() if set([int(aK) for aK in k]) >= set(list)]
    print(found) 
    

    posted in Pythonista read more
  • pulbrich

    dict = {'12345':6, '01928':7}
    list = [1, 2, 3]
    set_list = set(list)
    
    found = []
    for k in dict.keys():
      if set([int(aK) for aK in k]) >= set_list:
        found.append(k)
        
    print(found) 
    

    posted in Pythonista read more
  • pulbrich

    Try Think Python

    Though this is no video.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!