More than 1 button won’t show up
-
I have problem in which i cant make 2 buttons show up on the screen at once with this code
import ui
v = ui.View()
v.frame = (0,0,400,400)
v.name = 'test'b = ui.Button()
b.title = 'use'
b.background_color = 'white'
b.border_color = 'blue'
b.border_width = 1
b.corner_radius = 5
b.frame = (10,10,100,32)ba = ui.Button()
b.title = 'buy'
b.background_color = 'white'
b.border_color = 'blue'
b.border_width = 1
b.corner_radius = 5
b.frame = (110,10,100,32)a = ''
def tap(sender):
a = sender.title
print(a)
b.action = tap
v.add_subview(ba)
v.add_subview(b)
v.present('sheet')When i open the ui it only shows the button for the variable ba and doesnt show the variable b for the first button i made
Please tell me if i am doing something wrong or how to fix it
-
@ccc Poor guy, it is not easy to be a newbie 😅 in Python. there are so much ways to do the same
-
One more approach just for completeness:
import ui def tap(sender): print(sender.title) def make_button(title, frame): return ui.Button( title=title, frame=frame, action=tap, background_color='white', border_color='blue', border_width=1, corner_radius=5) view = ui.View(name='test', frame=(0, 0, 400, 400)) view.add_subview(make_button('use', (10, 10, 100, 32))) view.add_subview(make_button('buy', (110, 10, 100, 32))) view.present('sheet')
-
Holy БЛЯДЬ i see now.
I am such a тупица ТоТ
-
@NewbieCoder Thanks to Google translate 👍
-
@cvp What do you mean
-
He pasted your text into https://translate.google.com to translate it into something that he could understand.
-
Exactly but I use the app
-
@NewbieCoder, lots of good answers here, but for completeness sake I would like to claim that there was nothing technically wrong with your original code, beyond the copy-paste error where you created
b
andba
, but set the attributes ofb
twice.
-
last edited by
-
@cvp, I read his answer three times, and could not see it saying the same thing.
-
@mikael Ok, not exactly but +- 🙄