有谁知道是什么导致了这种情况?我的 Kivy RecycleView 在可编辑的后面有一个奇怪的静态版本 - 它不能以任何方式选择或更改。这让我觉得我可能有我所有 Kivy 小部件的重复版本?我很犹豫要不要粘贴我的所有代码,因为它会访问一个 api 并且在应用程序本身中包含凭据信息和许多个人信息。
双循环视图
class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior,
RecycleBoxLayout):
''' Adds selection and focus behaviour to the view. '''
class SelectableLabel(RecycleDataViewBehavior, Label):
''' Add selection support to the Label '''
index = None
selected = BooleanProperty(False)
selectable = BooleanProperty(True)
def refresh_view_attrs(self, rv, index, data):
''' Catch and handle the view changes '''
self.index = index
return super(SelectableLabel, self).refresh_view_attrs(
rv, index, data)
def on_touch_down(self, touch):
''' Add selection on touch down '''
if super(SelectableLabel, self).on_touch_down(touch):
return True
if self.collide_point(*touch.pos) and self.selectable:
return self.parent.select_with_touch(self.index, touch)
def apply_selection(self, rv, index, is_selected):
''' Respond to the selection of items in the view. '''
self.selected = is_selected
if is_selected:
print("selection changed to {0}".format(rv.data[index]))
else:
print("selection removed for {0}".format(rv.data[index]))
class RV(RecycleView):
def __init__(self, **kwargs):
super(RV, self).__init__(**kwargs)
self.data = [{'text': str(x)} for x in range(10)]
class GuiApp(App):
theme_cls = ThemeManager()
theme_cls.theme_style = 'Dark'
previous_date = ''
previous_date2 = ''
StartDate = ObjectProperty("Start Date")
EndDate = ObjectProperty("End Date")
def build(self):
self.pickers = Factory.AnotherScreen()
presentation = Builder.load_file("gui.kv")
return presentation
忽然笑
相关分类