S
S
SHADRIN2019-03-23 18:00:34
Python
SHADRIN, 2019-03-23 18:00:34

How will Kivy add a new GUI widget?

def build(self):
    self.al = AnchorLayout()
    self.bl = BoxLayout()
    self.bl = BoxLayout(orientation = 'vertical', size_hint = [.4, .4])

    self.regis = Button(text = 'Создать',on_press = self.btn_reg, font_size = 14) 
    # В кнопке прыгаем на btn_reg()
    self.bl.add_widget(self.regis)


    self.al.add_widget(self.bl)
    return self.al

  def btn_reg(self, instance):

    asd = Label( text='Привет' ) 
    return asd # первая попытка не работает
    ##--------------------##

    return Label( text='Привет' )  # Так тоже не работает
    ##--------------------##
    asd = Label( text='Привет' ) 
    bs = BoxLayout()
    bs.add_widget(asd)
    return bs 

    # Тоже не пашет
    # Не могу создать новый виджет никакой((

The question is how when you click on the button to create a new widget, Google does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-03-23
@shadrin_ss

So try

def btn_reg(self, instance):

    asd = Label( text='Привет' )
    self.al.add_widget(asd)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question