Skip to content

Instantly share code, notes, and snippets.

@GreyGnome
Created July 26, 2016 13:39
Show Gist options
  • Save GreyGnome/1df1c7cbdc9756f84bee8311c88702cf to your computer and use it in GitHub Desktop.
Save GreyGnome/1df1c7cbdc9756f84bee8311c88702cf to your computer and use it in GitHub Desktop.
Remove then add widget to a BoxLayout
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.button import Button
import time
kv = '''
BoxLayout:
canvas:
Color:
rgb: 0.2, 0.2, 1
Rectangle:
pos: self.pos
size: self.size
Button:
text: '1. Button'
Button:
text: '2. Button'
Button:
text: '3. Button'
'''
class App2(App):
def build(self):
loader = Builder.load_string(kv)
first_button = loader.children[2]
loader.remove_widget(first_button)
loader.add_widget(first_button, index=2)
loader.do_layout()
first_button.canvas.ask_update()
return loader
def greet(self):
print "Moving App!!!"
if __name__ == '__main__':
App2().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment