Forum Archive

Printing input from textview

janAaron

Hi! I wrote a code to let people write stuff in a box, using ui. However I want the program to output whatever the user types in the textview through the terminal. How do I do that?

Here is my code:

import ui
import console

def textimput(sender):

view = ui.View()
view.name = "yuppy"
view.background_color = 0.00, 1.00, 1.00
view.present("sheet")

text = ui.TextField()
text.flex = "LRTB"
text.action = textimput
view.add_subview(text)
text.center = (view.width 0.5, view.height 0.5)

As you can see, I haven't defined the method textimput yet because I don't know how to get the program to put the written text in the terminal.

JonB

Use print

By the way, for posting code to the forums, you will want to start a new line, then type three backticks
```
Then paste your code, then end with three backticks again. Then your code will be formatted like this:

def textinput(sender):
    print sender.text

For writing variables inside a paragraph, use single backticks, like this.

Backticks are annoying to get to on ios, you press the ?123 button, then hold the single quote charatcter, then select the one on the left. I created an autocorrect shortcut where three commas in a row get replaced with 3 backticks,

janAaron

I got print, but what do I print?