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.
I need help(again)
-
I cant exactly pinpoint what im doing wrong here but im in trouble again)))))
The a = sender.title line is being completely ignored and nothing shows up in the console
v = ui.View() v.frame = (0,0,400,400) v.name = 'test' b = ui.Button() b.title = 'use' b.action = 'tap' b.background_color = 'white' b.border_color = 'blue' b.border_width = 1 b.corner_radius = 5 b.frame = (10,10,100,32) v.add_subview(b) ba = ui.Button() ba.title = 'buy' ba.action = 'tap' ba.background_color = 'white' ba.border_color = 'blue' ba.border_width = 1 ba.corner_radius = 5 ba.frame = (110,10,100,32) v.add_subview(ba) a = '' v.present(“sheet”) while 0 == 0: def tap(sender): '@type sender: ui.Button' a = sender.title print(a)
-
Lose the quotes around tap because you want the function, not a string.
Define tap() at the top of you file (before you use it).
Also, you want to surround your code with three backticks.
-
@NewbieCoder, did you already get past this is issue? Hard to tell with multiple posts - maybe keep working on these in the same thread to make the chronology easier to follow? Also, please put all the code you share between three backticks to make it format properly and to make it easier for people helping you.
Regarding this code, hard to tell without the formatting, but at least the
while 0 == 0
loop should be unnecessary. -
import ui #import needed library def tap(sender): #define function before it is called print(sender.title) v = ui.View() v.frame = (0,0,400,400) v.name = 'test' b = ui.Button() b.title = 'use' b.action = tap b.background_color = 'white' b.border_color = 'blue' b.border_width = 1 b.corner_radius = 5 b.frame = (10,10,100,32) v.add_subview(b) ba = ui.Button() ba.title = 'buy' ba.action = tap ba.background_color = 'white' ba.border_color = 'blue' ba.border_width = 1 ba.corner_radius = 5 ba.frame = (110,10,100,32) v.add_subview(ba) v.present('sheet')
-
I highly recommend the UI Tutorial link that @brumm has provided above because it does a great job of building from simple to complex.
-
@mikael the while loop is because i am making an idol clicker type thing and want inputs every time the button is pressed (i started out typing what the buttons would say on them to get the general idea)
-
The while True: loop is not needed because view.present() will keep your window active and responding to button clicks, etc. until the user clicks the X in the upper right, does a multi-finger swipe down, etc.