• burns

    Thank you so much for replying that fast. The btnclicked get called when using retain_global.

    @JonB To answer your question I am building an hybrid app being partly written in python and javascript. Therefore I need the native WKWebView which gives more javascript performance than the normal webview, Another advantage of WKWebview is the bidirectional javascript to python communication.

    In fact the posted code is only the isolation of the button not clicked problem in my „hybrid“ app. For the settings panel of my app I would like to use pythonistas ui package, because I like to do it with pythonistas ui designer.

    posted in Pythonista read more
  • burns

    I added a pythonista ui view as a subview to an underlying native view.

    Displaying labels and buttons is working fine. So I assume that I made no big error here.

    Where my problem starts, is when I try to wire the button actions to methods in my view code.

    I did it certainly the wrong way because the action delegates of the buttons are simply not called.

    Here is my progress so far. Has anybody an idea how to connect the button action to methods in pythonista code?

    from objc_util import *
    import  ui
    
    WKWebView = ObjCClass('WKWebView')
    UIViewController = ObjCClass('UIViewController')
    
    def btnclicked(sender):
        print('btnclicked')
    
    @on_main_thread
    def main():
        rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
        tabVC = rootVC.detailViewController()
        
        CustomViewController = create_objc_class('CustomViewController', UIViewController, methods=[], protocols=[])
        vc = CustomViewController.new().autorelease()
        vc.title = 'View Test'
        
        vc.navigationItem().rightBarButtonItems = []
        webView = WKWebView.new().autorelease()
    
        vc.view = webView
        tabVC.addTabWithViewController_(vc)
        
        v = ui.View()
        v.name = 'View Test'
        v.width = 600
        v.height = 300
        v.background_color = 'red'
        button = ui.Button(title='ok')
        button.center = (v.width * 0.5,v.height * 0.5)
        button.flex = 'LRTB'
        button.action = btnclicked
        v.add_subview(button)
        
        webView.addSubview_(v)
        
    
    if __name__ == '__main__':
        main()
    

    PS: using a pythonista ui view instead of a native view as a super view is working as expected. (e.g. buttons delegates are called) So I assume it has something to do with the native view.

    posted in Pythonista read more
  • burns

    @omz thank you for the fast reply. Though the answer is disappointing.

    I completely disagree with Apples position.

    Pythonista isn't a document scanner or calculator. No 2D-Game, no text writer etc. But it is an IDE. So it's all of them.
    Apple, this is nonsense.

    I hope they will correct this mistake in the near future. Maybe this is one step towards that.

    posted in Pythonista read more
  • burns

    hi,

    i'm trying to implement an audio player who plays music, even in background or when the device is turned off. I have tested all code examples from this thread, but no ones work. Immediately after clicking the home-Button or turning of the device the sound is fading out.

    It seams to me, that Pythonista doesn't meet the requirements from Apple to play music in background .
    Am i wrong?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!