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.


    Tableview_select

    Pythonista
    2
    7
    2299
    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.
    • Appletrain
      Appletrain last edited by

      I’ve written a custom input form sub-classed from input form dialog. It works fine stand alone. It also works fine when called from a button on my tableview form. When I call it from tableview select, it blows out. Somehow container_view becomes None. I’ve tried everything I can think of, including calling the button action. Any thoughts?

      mikael 1 Reply Last reply Reply Quote 0
      • mikael
        mikael @Appletrain last edited by

        @Appletrain, have you tried decorating the tableview_selected method with @on_main_thread?

        Appletrain 1 Reply Last reply Reply Quote 0
        • Appletrain
          Appletrain @mikael last edited by

          @mikael Thanks @mikael, doesn’t help. Same error, same place. What I can’t understand is why it works one place and not another. I stripped every thing out of the two functions so they are doing exactly the same thing. On blows up, the other does’t.

          mikael 1 Reply Last reply Reply Quote 0
          • mikael
            mikael @Appletrain last edited by

            @Appletrain, can you share your stripped-out code?

            Appletrain 1 Reply Last reply Reply Quote 0
            • Appletrain
              Appletrain @mikael last edited by ccc

              @mikael, this is about as stripped out as I can make it

              def tableview_add(self):
                          trxRec = {}
                          result = {}      
                         # trxRec = {'account': self.selected_account}
                          result = bucks_dialog(trxRec)    # this works
                      
                  def tableview_update(self):
                          result = {}
                          trxRec = {}
                         # trxRec = self.selected_item
                          result = bucks_dialog(trxRec)    # this blows out - self.container_view changes to None
                      
                  def tableview_did_select(self, tv, section, row):
                          self.tableview_update()
                      
              def transaction_action(sender):    # sender is ui.button
                  sender.tint_color = 'blue'
                  ds.tableview_add()
              

              Bucks_dialog is a custom form_dialogs from dialogs

              Error is:

              Pythonista3/Documents/Projects/bucks/bucks_form.py", line 217, in trans_type_action
              self.container_view.name = segment_names[ind]
              AttributeError: 'NoneType' object has no attribute 'name'

              self.container_view is none (form_dialog)

              mikael 1 Reply Last reply Reply Quote 0
              • mikael
                mikael @Appletrain last edited by mikael

                @Appletrain, sorry, my faulty memory. You need to decorate the method with @ui.in_background. This will mean that you do not get the method return value in the same thread, so you need to set the tableview values within the backgrounded method, or look at this thread.

                Appletrain 1 Reply Last reply Reply Quote 0
                • Appletrain
                  Appletrain @mikael last edited by

                  @mikael, thank you, that took care of it. I had tried that, but I put it at the update function not the select function.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors