I’m trying to create a simple UI in Pythonista for my iPhone 6.
I’d like to have a single line text box and a button at the top of the screen. The button should be at the upper right and be sized to fit the button’s name text.
The text box should be the same height as the button and be located to the left of the button and fill the remaining width. I will then fill the remainder of the screen with a SceneView (not yet added).
The idea is that you can type some text into the text field and then click the button to apply the text to the scene. I would rather not use a layout file and keep it all in a single script file so I’m trying to do it from code.
I’ve experimented with this using the UI module docs but can’t get it quite working.
Here’s what I have. Any suggestions on how to get this to do what I want?
import ui
view = ui.View()
view.name = 'test UI'
view.background_color = 'black'
r = ui.Button(title='Add Item')
r.background_color = 'orange'
r.flex = 'BL'
view.add_subview(r)
s = ui.TextField()
s.flex = 'BR'
view.add_subview(s )
view.present('fullscreen')