• Cethric

    In general the _appex model is not really meant to be used as it is the backend for the appex wrapper module. Try using:

    import appex
    print(appex.get_text())
    print(appex.get_urls()) # or appex.get_url()
    

    posted in Pythonista read more
  • Cethric

    From memory my OpenGLES library had very rudimentary header parsing (If its not on the github repo its probably on my iPad) if you wanted to have a look at it and use components of it. From memory it was very messy, it did what it needed to do but it wasn't very nice.

    posted in Pythonista read more
  • Cethric

    @wolf71 objc_util dynamically creates its own copy of the AudioComponentDescription hence your ArgumentError This can be resolved either by using the objc_util version (can remberer exactly how to do that) or you specify that you want to use your copy. Eg

    from objc_util import *
    import ctypes
    
    AVAudioUnit=ObjCClass('AVAudioUnit')
    AVAudioUnitComponent=ObjCClass('AVAudioUnitComponent')
    AVAudioUnitComponentManager=ObjCClass('AVAudioUnitComponentManager')
    
    #
    # componentType,componentSubType,componentManufacturer is OSType
    #
    # ref:  developer.apple.com/reference/audiotoolbox/audiocomponentdescription
    #
    class AudioComponentDescription(ctypes.Structure):
        _fields_=[('componentType',ctypes.c_char_p),('componentSubType',ctypes.c_char_p),('componentManufacturer',ctypes.c_char_p),('componentFlags',ctypes.c_uint32),('componentFlagsMask',ctypes.c_uint32)]
        
    anyEffect = AudioComponentDescription('aufx','dcmp','appl',0,0)
    availableEffects = AVAudioUnitComponentManager.sharedAudioUnitComponentManager().componentsMatchingDescription_(anyEffect, argtypes=[AudioComponentDescription])
    

    posted in Pythonista read more
  • Cethric

    @starrshaw the sound is being played twice but the call to stop it playing is only made once.

    import sound, time
    y = "room_One.mp3"
    x = sound.play_effect(y)
    sound.play_effect(y)  # <- This call can be removed
    time.sleep(5)
    sound.stop_effect(x)
    

    posted in Pythonista read more
  • Cethric

    @ltddev I believe that the classes for this are exposed through the objc_util extension that pythonista has but there is no pre-written library/module for accessing the widget.

    posted in General Discussion read more
  • Cethric

    Without seeing the data or the complete stack trace I can only guess what the issue is. But two possibilities come to mind:

    1. line is a white space character so there is nothing to split which results in 2).
    2. splitUP has a value of ['xy'] instead of ['x', 'y']
      Either way try printing the value of splitUP Without breaking it first. IE print(splitUP) and see what that gives.

    posted in Pythonista read more
  • Cethric

    I assume that you have your data already in a list form and that you have some understanding of how pythonista UI's work, if not let me know and I will try and explain it as best I can.
    The following is a brief outline of what needs to be done:

    import ui
    data = [x for x in range(0, 50)]
    datasource = ui.ListDataSource(data)
    tv = ui.TableView()
    tv.data_source = datasource
    tv.delegate = datasource
    
    def selectitem(*args):
        view = ui.View(title='{}'.format(args[1]))
        label = ui.Label()
        label.text = "{}, {}, {}".format(*args)
        label.size_to_fit()
        view.add_subview(label)
        view.background_color = 'white'
        nav.push_view(view)
    datasource.tableview_did_select = selectitem
    
    nav = ui.NavigationView(tv)
    
    nav.present()
    

    Hope this helps.

    posted in Pythonista read more
  • Cethric

    If you are really concerned about memory there is a lot more in your code that can be cleaned up, mainly unnecessary variables, etc. But if you need help with that then we can go over it after.
    As to the rockets not deleting correctly, I get an error before it can even delete due to non-existent indecies in the list (due to the list being modified from in the loop that is not really friendly with your code). To resolve that I completely changed your for-loop to the following:

    for i, missile in enumerate(self.missiles):
                print(i, missile.position)
                if missile.position.y > self.size_of_screen.y - 100:
                    missile.remove_from_parent()
                    self.missiles.remove(missile)
    

    Also Node.remove_from_parent() needs to be called for the object to be removed from the render list.

    posted in Pythonista read more
  • Cethric

    @mrcoxall: does the last image display once the loop is finished? I just tested it (using different images) and it seemed that the only issue was that the loop was blocking the UI thread, so it couldn't update and render the new information. To fix this just add @ui.in_background above def start_button_touch_up_inside(sender) and it should work fine.

    posted in Pythonista read more
  • Cethric

    Yes .tmp.html can simply be changed to any value you want. The following code does this automatically for you:

    def createTables(text=None, name=None):
        if text is None:
            text = editor.get_text()
        if name is None:
            name = '{}.html'.format(os.path.basename(editor.get_path()))
        path = os.path.join(os.path.expanduser('~/Documents'), name)
        with open(path, 'wb') as f:
            f.write(TEMPLATE.format('\n'.join([
                TEMPLATE_ROW.format(x) for x in text.split('\n') if x != ''
            ])))
        webbrowser.open("file://{}".format(path))
    

    However I would recommend against this on the basis that, if the .html was not appended to the name (or even just changing the name in any way shape or form) then it will replace the contents of the file you are working on. While this might be decent when rendered out it is not as easy to read as markdown is as plaintext. Hence I have used .tmp.html as only one file can be open at a time and this reduces 'clutter' from your documents folder (instead of dozens of xyz.md.html duplicate files there is just one .tmp.html). .tmp.html can be deleted whenever you want and will not damage you script file. (Also adding the prefix of . means the file will be hidden (reducing visual clutter)). Sorry if this has gone to far off on a wild tangent. Hope it answers your question as well...

    posted in Editorial read more

Internal error.

Oops! Looks like something went wrong!