Reputation: 31
i am new in kivy.
i got this error over and over
File "_event.pyx", line 255, in kivy._event.EventDispatcher.bind (kivy_event.c:3629)
KeyError: 'pos_hint'
this is my code:
class RiegosBoxLayout(BoxLayout):
def __init__(self, **kwargs):
super(RiegosBoxLayout, self).__init__(**kwargs)
self.orientation= "vertical"
lb= Label(text= "Riegos programados", font_size= '30dp', bold= True, size_hint= (1, .10))
self.add_widget(lb)
db= sqlite3.connect('../db/dbInvernadero.s3db')
cursor = db.cursor()
cursor.execute("select ID, descripcion from tbRiegos")
la= ListAdapter(
data=["{}".format(i[1]) for i in cursor.fetchall()],
selection_mode='single',
allow_empty_selection=False,
cls= ListItemButton)
#lv = ListView( item_strings=[str(i[1]) for i in cursor.fetchall()])
self.add_widget(la) # if i pass lv, it goes ok
db.close()
class MainScreen(Screen):
def __init__(self, **kwargs):
super(MainScreen, self).__init__(**kwargs)
tb_panel= TabbedPanel(do_default_tab=False, size_hint=(1,1), pos_hint= {'center_x': .5, 'center_y': .5})
tabs= ["Operaciones", "Riegos", "Valvulas", "Radiacion", "Configuracion"]
for tb in tabs:
if (tb == "Riegos"):
tbi=TabbedPanelItem(text=tb)
tbi.add_widget(RiegosBoxLayout())
tb_panel.add_widget(tbi)
else:
tb_panel.add_widget(TabbedPanelItem(text=tb))
self.add_widget(tb_panel)
class MainApp(App):
def build(self):
# Create the screen manager
sm = ScreenManager()
sc=MainScreen()
sm.add_widget(sc)
return sm
if __name__ == '__main__':
MainApp().run()
Upvotes: 3
Views: 588
Reputation: 14834
ListAdapter
is not a Widget
. It works when you use ListView
because that is a Widget
. You need to provide the ListAdapter
to the ListView
:
lv = ListView(adapter=la)
self.add_widget(lv)
Upvotes: 2