2017-12-08 2 views
0

두 개의 ScrollView 위젯이 있고 각각의 Scroll_y를 동기화하고 싶다면. 내 코드에서 Scroll_A에서 스크롤하는 경우에도 자체적으로 이동하지 않으며 Scroll_B는 실시간으로 이동하지 않습니다. Scroll_y와이 두 ScrollViews를 실시간으로 동기화하려면 어떤 종류의 코드를 작성해야합니까?kivy each scroll_y

python 
from kivy.app   import App 
from kivy.lang   import Builder 
from kivy.uix.scrollview import ScrollView 
from kivy.properties  import ObjectProperty 

class Scroll_A(ScrollView): 
    scroll_b = ObjectProperty(None) 
    def on_scroll_move(self, touch): 
     self.scroll_b.scroll_y = self.scroll_y 

class Scroll_B(ScrollView): 
    def on_scroll_move(self, touch): 
     pass 

Mykv = ''' 
GridLayout: 
    cols: 2 
    spacing: 100, 100 
    padding: 50, 50, 50, 50 
    Scroll_A: 
     id: scroll_a 
     scroll_b: scroll_b 
     do_scroll_y: True 
     pos_hint: {'top': 1} 
     Label: 
      size_hint_y: None 
      text_size: self.width, None 
      color: 1,1,1,1 
      height: self.texture_size[1] 
      text: 'X' * 1000 
    Scroll_B: 
     id: scroll_b 
     do_scroll_y: True 
     pos_hint: {'top': 1} 
     Label: 
      size_hint_y: None 
      text_size: self.width, None 
      color: 1,1,1,1 
      height: self.texture_size[1] 
      text: 'Y' * 1000 
''' 

class MyApp(App): 

    def build(self): 
     return Builder.load_string(Mykv) 

if __name__ == '__main__': 
    MyApp().run() 

답변

0

내 문제가 해결되었습니다.

#python 
from kivy.app   import App 
from kivy.lang   import Builder 
from kivy.uix.scrollview import ScrollView 
from kivy.properties  import ObjectProperty 

class Scroll_A(ScrollView): 
    scroll_b = ObjectProperty(None) 
    pass 

class Scroll_B(ScrollView): 
    pass 

Mykv = ''' 
GridLayout: 
    cols: 2 
    spacing: 100, 100 
    padding: 50, 50, 50, 50 
    Scroll_A: 
     id: scroll_a 
     scroll_b: scroll_b 
     do_scroll_y: False 
     scroll_y: self.scroll_b.scroll_y 
     pos_hint: {'top': 1} 
     Label: 
      size_hint_y: None 
      text_size: self.width, None 
      color: 1,1,1,1 
      height: self.texture_size[1] 
      text: 'X' * 10000 
    Scroll_B: 
     id: scroll_b 
     do_scroll_y: True 
     pos_hint: {'top': 1} 
     Label: 
      size_hint_y: None 
      text_size: self.width, None 
      color: 1,1,1,1 
      height: self.texture_size[1] 
      text: 'Y' * 10000 
''' 

class MyApp(App): 

    def build(self): 
     return Builder.load_string(Mykv) 

if __name__ == '__main__': 
    MyApp().run()