omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Problems with ios15

    Pythonista
    6
    37
    5940
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JonB
      JonB last edited by

      Ok, so the modal_wait is broken -- the after wait prints before anything else!

      Possibly we need to add a time.sleep before the modaL wait to ensure the view is presented. Or we need some UI.in_background or on_main_view somewhere...

      Have you tried the dialogs module? This is exactly it's purpose, and you don't seem to be doing anything that requires anything custom.

      1 Reply Last reply Reply Quote 0
      • bosco
        bosco last edited by bosco

        This appears to be a problem only when running iOS 15 on an iPhone 12. The @JonB example runs fine on my iPad mini, but does not work on my iPhone 12 mini.

        I have run into the same problem with some rubicon-objc code i developed.

        # works on iPad, but fails on iPhone 12 mini
        while self.ispresented:
            waituntil = NSDate.alloc().initWithTimeIntervalSinceNow(.2)
            runLoop = NSRunLoop.currentRunLoop
            runLoop.runUntilDate(waituntil)
        

        Here are some links to others with a similar problem.
        https://stackoverflow.com/questions/69312354/failed-to-block-main-thread-with-runloop-on-ios15-with-device-iphone12
        https://developer.apple.com/forums/thread/691941

        I have other Pythonista scripts that use modal_wait() that do seem to work, so maybe there is a work around

        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by

          I wonder if this is a navigation view problem. Try presenting view without creating a nav view.

          1 Reply Last reply Reply Quote 0
          • bosco
            bosco last edited by

            @JonB Presenting the view directly without the nav view has the same issue on my iPhone 12. The first line in the console is after wait: None

            1 Reply Last reply Reply Quote 0
            • JonB
              JonB @JonB last edited by JonB

              A workaround might be to use a Lock.

              def show_list_dialog(items=None, *args, **kwargs):
                  items = items or []
                  tbl = ui.TableView(**kwargs)
                  tbl.data_source = ui.ListDataSource(items)
                  my_sel = {'value': None}
                  import threading
                  lock=threading.Lock()
                  class MyTableViewDelegate (object):
                      def tableview_did_select(self, tableview, section, row):
                          print('items:', tableview.data_source.items)
                          print('section, row:', section, row)
                          my_sel['value'] = tableview.data_source.items[row]
                          tableview.close()
                          lock.release()
                          print('in delegate: my_sel',my_sel['value'])
                  tbl.delegate = MyTableViewDelegate()
                  tbl.present(style='sheet')
                  lock.acquire()
                  #tbl.wait_modal()
                  print('after wait: ', my_sel['value'])
                  return my_sel['value']
              

              See if that solves it

              1 Reply Last reply Reply Quote 0
              • bosco
                bosco last edited by

                This code works on my iPhone 12.

                I added @ui.in_background to def select_author(sender)

                I will also test the Lock code.

                import ui
                #
                def show_list_dialog(items=None, *args, **kwargs):
                    items = items or []
                    tbl = ui.TableView(**kwargs)
                    tbl.data_source = ui.ListDataSource(items)
                    my_sel = {'value': None}
                    class MyTableViewDelegate (object):
                        def tableview_did_select(self, tableview, section, row):
                            print('items:', tableview.data_source.items)
                            print('section, row:', section, row)
                            my_sel['value'] = tableview.data_source.items[row]
                            tableview.close()
                            print('in delegate: my_sel',my_sel['value'])
                    tbl.delegate = MyTableViewDelegate()
                    tbl.present(style='sheet')
                    tbl.wait_modal()
                    print('after wait: ', my_sel['value'])
                    return my_sel['value']
                #
                w, h = ui.get_screen_size()
                view = ui.View(name="Frank's Library", bg_color='lightblue', frame=(0, 0, w, h))
                 
                @ui.in_background 
                def select_author(sender):
                    author_unique = ['Baldacci,David', 'Barr,Nevada', 'Bartol,Amy', 'Bernt,Eric', 'Brandt,Kylie', 'Bruni,Riccardo', 'Bryndza,Robert', 'Burke,James Lee', 'Burton,Mary', 'Butcher,Jim', 'Carlson,Tucker', 'Carrol,Sean', 'Case,Andrew', 'Chernov,Ron', 'Clayton,MegWaite', 'Coben,Harlan', 'Cole,Bobby', 'Connelly,Michael', 'Cornwell,Bernard', 'Cornwell,Patricia', 'Cowie,Amber', 'Crombie,Deborah', 'Crosby,Ellen', 'Cross,Katie', 'Cussler,Clive', 'Delaney,Matthew B.J.', 'Dilts,Tyler', 'Dorsey,Tim']
                    f = (0, 0, 400, 300)
                    selected_author = show_list_dialog(author_unique, frame=f, name='Select an Author')
                    print('list dialog returned:', selected_author)
                    global author_result
                    author_result.text = str(selected_author)
                    return
                 
                author_button = ui.Button(title='Author', frame=(10,5,350,100), border_color='black', border_width=2, background_color='#EAECEE', action=select_author, font=('Arial Rounded MT Bold',18))
                author_button.width=70
                author_button.height=40
                view.add_subview(author_button)
                #
                global author_result
                author_entry=''
                author_result = ui.TextView(name='author',frame=(100,5,250,40), border_color='black', border_width=3, text=author_entry, font=('Arial Rounded MT Bold',16))
                view.add_subview(author_result)
                 
                view.present('sheet')
                #nav_view = ui.NavigationView(view)
                #nav_view.present('sheet')
                

                @

                1 Reply Last reply Reply Quote 1
                • JonB
                  JonB last edited by

                  Ok, that makes sense. You can't have a wait_modal on the main thread, since you wouldn't be able to interact with the gui.

                  1 Reply Last reply Reply Quote 1
                  • frankL
                    frankL last edited by

                    Thank you bosco. That fix works for me on iPhone12.

                    cvp 1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp last edited by cvp

                      @jonb @bosco @frankL 🥂

                      1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp @frankL last edited by

                        @frankL sorry to have searched in the bad direction...

                        1 Reply Last reply Reply Quote 0
                        • dracosvid
                          dracosvid last edited by dracosvid

                          This post is deleted!
                          1 Reply Last reply Reply Quote 0
                          • krishay.baxte
                            krishay.baxte last edited by

                            This post is deleted!
                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Powered by NodeBB Forums | Contributors