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.
Whats wrong with this code?
-
Hi everyone!
I wrote this ui code, but the button isnt showing up. What's up?
Here's the code:
import ui def pressed (sender): sender.tint_color = 1.00, 0.00, 0.00 view = ui.View() view.name = "tic tac toe" view.background_color = 0.90, 0.90, 0.90 view.present("sheet") button = ui.Button() button.flex = "LRTB" button.action = pressed view.add_subview(button) button.center = (view.width *0.5,view.height *0.5) button.title = "nothing" button.background_image = ui.Image('Ant')
-
When you create a button without a title or icon, it gets a zero width/height, which makes it invisible. You'd either have to set the size explicitly, or pass a title to the constructor:
button = ui.Button(title='nothing')
Your next problem will probably be that the background image doesn't show up. Use
ui.Image.named('Ant')
instead ofui.Image('Ant')
to fix that. -
Thank you!