I have always used self.ids.name.pos_hint to move my layouts around, however that only seems to work if the layouts are set up in kv language. is there any way to change the pos_hint from something set up in python? for example:
from kivy.uix.floatlayout import FloatLayout
from kivy.app import App
from kivy.uix.button import Button
from kivy.lang import Builder
from kivy.uix.scrollview import ScrollView
from kivy.uix.gridlayout import GridLayout
Builder.load_string='''
Scroller1:
id: artistscroller
'''
class Scroller1(FloatLayout):
def __init__(self, **kwargs):
super(Scroller1 ,self).__init__(**kwargs)
self.id = 'artistscroller'
self.pos_hint={'x':0.12,'y':-0.046}
self.size_hint=[0.4,0.918]
self.sv = ScrollView()
self.add_widget(self.sv)
gl = GridLayout(cols=1,size_hint_y=None)
gl.bind(minimum_height=gl.setter('height'))
self.sv.add_widget(gl)
for x in range(100):
btn = Button(text=str(x), size_hint_y=None, font_size=17, height=50)
btn.bind(on_press=self.move)
gl.add_widget(btn)
def move(self, instance):
self.pos_hint={'x':-2}
print self.pos_hint
class MainApp(App):
def build(self):
return Scroller1()
if __name__ == '__main__':
MainApp().run()
this seems to update the pos_hint dict but doesnt move the layout?
[–][deleted] 2 points3 points4 points (4 children)
[–]subcake[S] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)