Python file
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.core.window import Window
from kivy.config import Config
from kivymd.uix.list import OneLineListItem
#Ukuran window
Config.set('graphics', 'width', '1000')
Config.set('graphics', 'height', '600')
Config.set('graphics', 'resizable', False)
#Set window preview
Window.size = (1000, 600)
class MainApp(MDApp):
def build(self):
return Builder.load_file("interface.kv")
def test(self):
for i in range(20):
item = OneLineListItem(
text=f'Items number {i}'
)
self.root.ids.items.add_widget(item)
MainApp().run() ```
kivy file
#:kivy 2.3.0
FloatLayout:
#——————–Header——————-
Image:
source: ‘ex.png’
size_hint: (0.3,0.3)
pos_hint: {‘x’:-.05,’y’: .75}
MDLabel:
text: "Invoice System"
font_size: '50sp'
halign: 'center'
pos_hint: {'y': .4}
#—————Item—————-
MDTextField:
mode: ‘fill’
hint_text: “???”
size_hint: (.4, .1)
pos_hint: {‘x’: .05, ‘y’: .65}
MDTextField:
mode: 'fill'
hint_text: "???"
size_hint: (.14, .1)
pos_hint: {'x': .46, 'y': .65}
MDTextField:
mode: 'fill'
hint_text: "???"
size_hint: (.14, .1)
pos_hint: {'x': .61, 'y': .65}
MDFillRoundFlatIconButton:
style: 'filled'
text: "Add"
size_hint: (.1, .1)
pos_hint: {'x': .79, 'y': .65}
#———— Item List ——————–
MDBoxLayout:
md_bg_color: ‘#B5C0D0’
size_hint: (.846, .37)
pos_hint: {‘x’:.05, ‘y’: .25}
padding: 10
orientation: ‘vertical’
MDScrollView:
MDList:
id: items
#———— Last button ——————–
MDFillRoundFlatIconButton:
style: ‘filled’
text: “Make Invoice”
size_hint: (.21, .15)
pos_hint: {‘x’: .35, ‘y’: .08}
The problem is with the kivy file in the "Item List" section
I tried to create a scroll view inside a container which is a box layout. Inside the box layout, there is a scroll view that contains a list. The list is generated from a "for" loop which produces text to be displayed in the scroll view. However, the scroll view does not display the text generated from the loop.
Svin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.