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.


    Need help populating a textView

    Pythonista
    pythonista ui.textview ui.view textview
    2
    3
    2998
    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.
    • npr3ha
      npr3ha last edited by

      Hello, I’m very new at this, but I’ve read the Ui docs provided with the app and done some googling, and I still can’t find a solution to a problem I’m having. I’m trying to populate a textView with the first element of a list, then change the contents of the textView after a button is pressed. However, I cannot get the textView to show the first element of the list. The error I’m getting points to the last line of my code (line 36), and says: ‘NoneType’ object has no attribute ‘text’. In my UI file, ‘examElement’ is the Name of the textView. I think I’ve followed the format of how I’ve seen others use textViews, but maybe not. Hopefully it’s an easy fix! Thanks

      import ui
      
      strokeExamElements = ["You can't teach an old dog new tricks","Age? Month?","Close eyes tightly, open eyes wide","Facial droop","Visual Fields (4 quadrants)","Horizontal gaze tracking","Arm Drift","Leg Drift","Sensory: Arm","Sensory: Leg","Coordination: Arm (finger-nose)","Coordination: Leg (heel-shin)"]
      
      i = 0
      listOfPositives = []
      
      def nextExamElement():
      	global i
      	i += 1
      	view['examElement'].text = strokeExamElements[i]
      	
      def animation():
      	sender.alpha = 0.0 # fade out
      
      # must define the button_tapped action prior to loading the view
      def button_tapped(sender):
      	
      	buttonTitle = sender.title
      	
      	if buttonTitle == 'Negative':
      		nextExamElement()
      		
      	elif buttonTitle == 'Positive':
      		listOfPositives.append(strokeExamElements[i])
      		print(listOfPositives)
      		nextExamElement()
      		
      	elif buttonTitle == 'Show Results':
      		# TODO: add new view to display the list of positive elements
      		ui.animate(animation, duration=0.75)
      		pass
      
      view = ui.View()
      ui.load_view('MendExam').present('sheet')
      view['examElement'].text = strokeExamElements[i]
      
      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        In your main bit, you want

        view=ui.load_view(...)
        view.present(...)

        You were creating a view, but then loading and presenting a completely different view.

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

          Ah. Everything works now. Thank you!

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