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.


    Ui Tableview problem

    Pythonista
    2
    3
    423
    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.
    • daxo
      daxo last edited by daxo

      Hi,

      I just don't seem to be able to have an alert dialog prompt for the selected row in my table view.

      dialogs.alert('test', sender.items[sender.selected_row], 'Ok',hide_cancel_button=True)

      After I compute my data from my list and click a row. nothing pop in the alert dialog.

      Thank you for your kind help.

      here's images of my ui:
      https://imgur.com/IyHPN5z
      https://imgur.com/6tbWecq

      here's my code:

      import ui
      import people_also_ask
      import people_also_ask.request.session
      
      import clipboard
      import time
      import requests
      import dialogs
      from objc_util import nsurl,UIApplication
      
      
      def compute(sender):
      	data = v['textfield1'].text.split(",")
      	datasource = ui.ListDataSource(data)
      	v['tableview1'].data_source=datasource
      	v['tableview1'].reload_data()
      	
      	
      @ui.in_background
      def pressed(sender):
      	dialogs.alert('test', sender.items[sender.selected_row], 'Ok',hide_cancel_button=True)
      
      v = ui.load_view()
      v.present('sheet')
      
      
      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @daxo last edited by cvp

        @daxo try

        def compute(sender):
            data = v['textfield1'].text.split(",")
            v['tableview1'].data_source.items = data
            v['tableview1'].reload_data()
        

        Do not recreate a datasource each time, only reload its items

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

          wow @cvp, thank you for your solution!

          I clearly understands my mistake now.

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