i am trying to set the font for the Arabic language in kivymd for menu items in kivymd, I didn't find any solution for this after reviewing the docs well, so does anyone has an idea?
Use my example code, for this code to work you must download a ttf font file that contains the Arabic language characters and save it into the same folder where you're executing the code below, I downloaded JannaLTBold.ttf:
Here is the code by jbsidis:
from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.list import OneLineListItem
from kivymd.uix.card import MDCard
KV = '''
Screen:
BoxLayout:
id: m5
spacing: dp(10)
#padding: dp(20)
pos_hint: {"center_x": .5, "center_y": .55}
orientation: "vertical"
BoxLayout:
size_hint_y: None
height: self.minimum_height
pos_hint: {"center_x": .5, "center_y": .4}
orientation: "vertical"
ScrollView:
id: rvvv9
bar_color: [0,0,1,.5]
bar_inactive_color: [1,1,1,0]
bar_width: dp(5)
BoxLayout:
id: container
padding: dp(10)
spacing: dp(100)
default_size: None, dp(75)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
<NN>:
GridLayout:
cols: 2
spacing: dp(30)
OneLineListItem:
markup: True
text: "[font=JannaLTBold.ttf] jbsidis شخص في هذا العالم يسمى: جبسيديس"
MDCard:
size_hint: 1,None
Image:
source: "Photos/pro.jpg"
'''
class NN(MDCard):
pass
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
def on_start(self):
for i in range(20):
self.root.ids.container.add_widget(
NN()
)
Test().run()
The result should be like the image:
jbsidis
Related
I'm trying to make a book reader in python, and I want to put the covers in a gridlayout with 2 columns and make ir scrollable, but I'm having an issue. I've already seen some questions about ScrollView, but nothing worked for me until now.
Here is a piece of my code:
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
from kivymd.uix.floatlayout import MDFloatLayout
from kivymd.uix.tab import MDTabsBase
class Library(Screen):
pass
class Book(Screen):
pass
class SM(ScreenManager):
pass
KV = '''
SM:
Library:
Book:
<Library>:
name: "lib"
MDBoxLayout:
orientation: "vertical"
MDToolbar:
id: t_b
title: "Library"
right_action_items: [["magnify", lambda x: x]]
MDTabs:
id: tabs
MDFloatLayout:
ScrollView:
pos_hint_y: None
pos_y: 0
size_hint_y: None
height: root.height
GridLayout:
cols: 2
spacing: "10dp"
size_hint_y: None
height: self.minimum_height
MDCard:
on_touch_down:
app.root.current = "book"
size_hint_y: None
height: "300dp"
Image:
source: "cover.png"
MDCard:
on_touch_down:
app.root.current = "book"
size_hint_y: None
height: "300dp"
Image:
source: "cover.png"
MDCard:
on_touch_down:
app.root.current = "book"
size_hint_y: None
height: "300dp"
Image:
source: "cover.png"
MDCard:
on_touch_down:
app.root.current = "book"
size_hint_y: None
height: "300dp"
Image:
source: "cover.png"
MDBottomNavigation:
MDBottomNavigationItem:
text: "Library"
icon: "book-variant-multiple"
MDBottomNavigationItem:
text: "History"
icon: "history"
MDBottomNavigationItem:
text: "Settings"
icon: "dots-horizontal"
<Book>:
name: "book"
'''
class Tab(MDFloatLayout, MDTabsBase):
pass
class Aplication(MDApp):
def build(self):
screen = Builder.load_string(KV)
return screen
def on_start(self):
tags = ['Action', 'Romance', 'Horror', 'Adventure']
for tag in tags:
self.root.get_screen("lib").ids.tabs.add_widget(Tab(title=tag))
if __name__ == "__main__":
Aplication().run()
It makes a ScrollView with the cards, but it's overlaying the toolbar and the tabs. What should I do?
from kivymd.app import MDApp
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.properties import ObjectProperty
class ContentNavigationDrawer(BoxLayout):
"""This class manage the navigation drawer contents"""
screen_manager = ObjectProperty()
nav_drawer = ObjectProperty()
class MyApp(MDApp):
def build(self):
"""Return the main kivy file and set themes """
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = 'BlueGray'
self.theme_cls.accent_palette = "Teal"
return Builder.load_file("main.kv")
MyApp().run()
and the kv file
<ContentNavigationDrawer>:
MDBoxLayout:
orientation: "vertical"
spacing: dp("8")
padding: dp("8")
ScrollView:
MDList:
OneLineIconListItem:
text: "hexagon"
on_press:
root.nav_drawer.set_state("close")
root.screen_manager.current = "mainScreen"
IconLeftWidget:
icon: 'hexagon'
MDScreen:
MDToolbar:
id: toolbar
title: "Hexagon"
md_bg_color: app.theme_cls.primary_color
specific_text_color: 1, 1, 1, 1
pos_hint: {"top": 1}
elevation: 9
icon: 'account-circle'
left_action_items: [["menu", lambda x: nav_drawer.set_state("open")]]
MDNavigationLayout:
x: toolbar.height
ScreenManager:
id: screen_manager
MDScreen:
name: "mainScreen"
BoxLayout:
orientation: 'vertical'
size: root.width, root.height
ScrollView:
do_scroll_x: True
do_scroll_y: True
size_hint: (1, .85)
bar_width: 10
bar_color: (1, 0, 0 ,1)
scroll_type: ["bars", "content"]
pos_hint: {'top': 1.0 - toolbar.height/float(root.height)}
GridLayout:
id: labels_layout
size_hint_y: None
height:self.minimum_height
size_hint_x: None
width: self.minimum_width
cols: 1
spacing: "5dp"
padding: "5dp"
MDLabel:
id: big_text_label
text: "asldklsa\nasdsaf\nssss\n"
width: self.texture_size[1]
height: self.texture_size[1]
MDNavigationDrawer:
id: nav_drawer
ContentNavigationDrawer:
screen_manager: screen_manager
nav_drawer: nav_drawer
test_screen_shot
I want to change the color of the toolbar I tried almost everything to do it
like md_bg_color: app.theme_cls.primary_color and md_bg_color: .2, .2, .2, 1
And the text goes beyond the boundaries even of the app if i add some widgets to get back
text to its area the it goes under the toolbar
Using:
Python 3.9, dev kivyMD 2.0, editor pycharm
Use:
from kivymd.app import MDApp
from kivy.lang import Builder
KV = """
<ContentNavigationDrawer>:
MDBoxLayout:
orientation: "vertical"
spacing: dp("8")
padding: dp("8")
ScrollView:
MDList:
OneLineIconListItem:
divider: None
text: "hexagon"
on_press:
app.root.ids.nav_drawer.set_state("toggle")
#root.screen_manager.current = "mainScreen"
IconLeftWidget:
icon: 'account'
## BoxLayout:
## canvas.before:
## Color:
## rgba: [1,.3,0,1]
## Line:
## width: dp(1)
## rounded_rectangle:
## (self.x, self.y, self.width-dp(20), dp(43),\
## dp(12),dp(12),dp(12),dp(12),\
## dp(50))
OneLineIconListItem:
divider: None
text: "hexagon"
on_press:
app.root.ids.nav_drawer.set_state("toggle")
#root.screen_manager.current = "mainScreen"
IconLeftWidget:
icon: 'hexagon'
OneLineIconListItem:
divider: None
text: "Edit"
on_press:
app.root.ids.nav_drawer.set_state("toggle")
#root.screen_manager.current = "mainScreen"
IconLeftWidget:
icon: 'pencil'
OneLineIconListItem:
divider: None
text: "Home"
on_press:
app.root.ids.nav_drawer.set_state("toggle")
#root.screen_manager.current = "mainScreen"
IconLeftWidget:
icon: 'home'
OneLineIconListItem:
divider: None
text: "Likes"
on_press:
app.root.ids.nav_drawer.set_state("toggle")
#root.screen_manager.current = "mainScreen"
IconLeftWidget:
icon: 'star'
OneLineIconListItem:
divider: None
text: "hexagon"
on_press:
app.root.ids.nav_drawer.set_state("toggle")
#root.screen_manager.current = "mainScreen"
IconLeftWidget:
icon: 'hexagon'
OneLineIconListItem:
divider: None
text: "Search"
on_press:
app.root.ids.nav_drawer.set_state("toggle")
#root.screen_manager.current = "mainScreen"
IconLeftWidget:
icon: 'magnify'
Screen:
MDToolbar:
id: toolbar
pos_hint: {"top": 1}
title: "Hexagon"
md_bg_color: [1,0,0,1]
specific_text_color: [1, 1, 1, 1]
elevation: 0
left_action_items: [["menu", lambda x: nav_drawer.set_state("toggle")]]
right_action_items: [["account-circle", lambda x: print(222)]]
ScreenManager:
id: screen_manager
MDScreen:
name: "mainScreen"
FloatLayout:
BoxLayout:
id: m5
pos_hint: {"center_x": .5, "center_y": .38} #this will change if you change this Window.size = (330, 500)
orientation: "vertical"
ScrollView:
do_scroll_x: False #True
do_scroll_y: True
#size_hint: (1, .85)
bar_width: 10
bar_color: (1, 0, 0 ,1)
scroll_type: ["bars", "content"]
pos_hint: {'top': 1.0 - toolbar.height/float(root.height)}
GridLayout:
id: labels_layout
size_hint_y: None
height:self.minimum_height
size_hint_x: 1
#width: self.minimum_width
cols: 1
spacing: "5dp"
padding: dp(20)
MDLabel:
id: big_text_label
text: "\\n\\n\\n\\n\\n\\nWelcome to this New App.\\nYou will get a lot of benefits.\\n\\njbsidis recommendations are good so we can design in different ways."
MDNavigationDrawer:
id: nav_drawer
ContentNavigationDrawer:
screen_manager: screen_manager
"""
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
class ContentNavigationDrawer(BoxLayout):
"""This class manage the navigation drawer contents"""
screen_manager = ObjectProperty()
#nav_drawer = ObjectProperty()
class WeatherApp(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
pass
def build(self):
self.screen = Builder.load_string(KV)
return self.screen
WeatherApp().run()
Pictures:
I want to create an app in Python Kivy but I have stuck in some part. I want some additional show-ups in my app. Briefly, that is a selection app. So after make some sellections and and press "calculate" button, I want to show some hidden results. And when you confirm those results you should press "confirm" button that shows new selections which were hidden as well.
I can make it with BooleanProperty but in that case when height: "0dp" and opacity: 0, it still keeps unwanted empty space in widget. How can I get rid of the empty space ?
little comment: when you make opticity 1 while height:"0dp" remain, you will see they are still there. height 0 is not working properly.
here my main.py
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.checkbox import CheckBox
from kivy.uix.stacklayout import StackLayout
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.lang import Builder
from kivy.properties import BooleanProperty
from kivy.uix.screenmanager import ScreenManager, Screen
class MainWindow(Screen):
pass
def btn(self):
popup = Popup(content=Label(text='Wrong Password'),
size_hint=(None, None), size=(200, 200))
popup.bind(on_touch_down=popup.dismiss)
popup.open()
class SecondWindow(Screen):
isShownMenu = BooleanProperty(True)
bisShownMenu = BooleanProperty(True)
class WindowManager(ScreenManager):
pass
kv = Builder.load_file("my.kv")
class MyMainApp(App):
def build(self):
return kv
if __name__== "__main__":
MyMainApp().run()
and here is my.kv:
WindowManager:
MainWindow:
SecondWindow:
<ScrollViewExample#ScrollView>:
SecondWindow:
size_hint: 1, None
height: self.minimum_height
<Button>:
size_hint: .35 , 1
height: "20dp"
width: "20dp"
pos_hint: {"center_x": .5}
<MainWindow>:
name:"main"
BoxLayout:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
orientation: "vertical"
Image:
source:"vgs.png"
size_hint: 1, None
height: "110dp"
allow_stretch: True
keep_ratio: False
AnchorLayout:
anchor_x:"center"
anchor_y:"center"
BoxLayout:
orientation: "vertical"
spacing: "10dp"
size_hint: .8,.3
BoxLayout:
orientation: "horizontal"
Label:
text: "Username:"
color: 0,0,0,1
TextInput:
id: username
text: "***"
multiline: False
BoxLayout:
orientation: "horizontal"
Label:
text: "Password:"
color: 0,0,0,1
TextInput:
id: password
text: "***"
multiline: False
BoxLayout:
#orientation:"horizontal"
CheckBox:
color: 0,0,0,1
Label:
text: "Remember me"
color: 0,0,0,1
Button:
size_hint: .35 , 1
text: "Login"
pos_hint: {"center_x": .5}
on_release:
#root.btn() if username.text!="batu" or password.text!="1010" else None
app.root.current= "second" #if username.text=="batu" and password.text=="1010" else "main"
root.manager.transition.direction="left"
<SecondWindow>:
name:"second"
ScrollView:
GridLayout:
cols:1
height: self.minimum_height
row_default_height: "60dp"
size_hint_y: None
spacing:"10dp"
canvas.before:
Rectangle:
pos: self.pos
size: self.size
Image:
source:"vgs.png"
size_hint: 1, None
height: "110dp"
allow_stretch: True
keep_ratio: False
BoxLayout:
pading:"10dp"
spacing:"10dp"
orientation: "vertical"
BoxLayout:
orientation: "horizontal"
Label:
text:"Solid Content:"
color: 0,0,0,1
TextInput:
text:"enter %"
color: 0,0,0,1
BoxLayout:
orientation: "horizontal"
Label:
text:"Pressure:"
color: 0,0,0,1
TextInput:
text:"enter BAR"
color: 0,0,0,1
Button:
text:" Model Selection"
height: "20dp"
width: "20dp"
Button:
text:" Screen Selection"
Button:
text:"Rotor Selection"
Button:
text:"Motor & Reduction Selection"
Button:
text:"Calculate Selections"
on_press: root.isShownMenu = not root.isShownMenu
BoxLayout:
pading:"10dp"
spacing:"10dp"
size_hint: 1, None
height: "0dp" if root.isShownMenu else "80dp"
opacity: 0 if root.isShownMenu else 1
orientation: "vertical"
BoxLayout:
orientation:"horizontal"
Label:
text:"Calculated Flow:"
color: 0,0,0,1
Label:
text:"enter %"
color: 0,0,0,1
BoxLayout:
orientation:"horizontal"
Label:
text:"Calculated Pressure:"
color: 0,0,0,1
Label:
text:"00000"
color: 0,0,0,1
BoxLayout:
orientation:"horizontal"
Label:
text:"Fibre Lenght:"
color: 0,0,0,1
Label:
text:"000000"
color: 0,0,0,1
Button:
on_press: root.bisShownMenu = not root.bisShownMenu
text:"Confirm"
BoxLayout:
size_hint: 1, None
height: "0dp" if root.bisShownMenu else "80dp"
opacity: 0 if root.bisShownMenu else 1
orientation:"horizontal"
Label:
text:"cutter head material"
color: 0,0,0,1
Button:
text:"1.secim"
Button:
text:"2.secim"
Button:
text:"3.secim"
Button:
text:"4.secim"
BoxLayout:
size_hint: 1, None
height: "0dp" if root.bisShownMenu else "80dp"
opacity: 0 if root.bisShownMenu else 1
orientation:"horizontal"
Label:
text:"screen material"
color: 0,0,0,1
Button:
text:"1.secim"
Button:
text:"2.secim"
Button:
text:"3.secim"
Button:
text:"4.secim"
BoxLayout:
size_hint: 1, None
height: "0dp" if root.bisShownMenu else "80dp"
opacity: 0 if root.bisShownMenu else 1
orientation:"horizontal"
Label:
text:"blade material"
color: 0,0,0,1
Button:
text:"1.secim"
Button:
text:"2.secim"
Button:
text:"3.secim"
Button:
text:"4.secim"
BoxLayout:
size_hint: 1, None
height: "0dp" if root.bisShownMenu else "80dp"
opacity: 0 if root.bisShownMenu else 1
orientation:"horizontal"
Label:
text:"pot material"
color: 0,0,0,1
Button:
text:"1.secim"
Button:
text:"2.secim"
Button:
text:"3.secim"
Button:
text:"4.secim"
Button:
size_hint: .35 , 1
text: "Login"
pos_hint: {"center_x": .5}
on_release:
app.root.current= "main"
root.manager.transition.direction="right"
sorry for long codes. maybe it helps you in some parts.
I have solved my problem.
Well, if you want to add a different class to main your main class with a button or something, you should use "add_widget". But while you doing it, you need to convert your class to objectproperty first and than, use ids for id of your main widget;
cal2= ObjectProperty()
def btn4(self):
self.cal2 = MaterialS() #MaterialS is my class with different widget
self.ids.scd.add_widget(self.cal2, index=0) #scd is the id of my main widget, index =0 help me to insert to the bottom
I want that you can add and choose multiple dates. I tried to send a number with the button click button_nr but I don't know how I can pass it to the on_save function, so that I can change the self.ids.date_label(button_nr).text . If somebody has a better idea how to save multiple dates I'm open for suggestions.
Thank you
def on_save(self, instance, value, date_range):
date_value = datetime.datetime.strptime(str(value), "%Y-%m-%d")
date_value_eu = date_value.strftime("%d.%m.%Y")
self.ids.date_label1.text = str(date_value_eu)
def show_date_picker(self, button_nr):
print(button_nr)
date_dialog = MDDatePicker()
date_dialog.bind(on_save=self.on_save, on_cancel=self.on_cancel)
date_dialog.open()
The kv file part
MDRaisedButton:
on_release: root.show_date_picker(1)
You can use my code, I have designed this app in order to have a recycleview plus a search bar, the recycle list item in this example is moved into the pick date function and it changes the text of the list item widget (check the picture), here is the code by jbsidis (I am posting this after I commented your question):
from kivymd.app import MDApp
from kivy.lang.builder import Builder
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivymd.uix.list import OneLineIconListItem
from kivy.properties import (
StringProperty,
BooleanProperty,
ObjectProperty,
NumericProperty,
ListProperty,
OptionProperty,
)
Window.size = (330, 660)
kv = '''
#:import MDTextField kivymd.uix.textfield.MDTextField
<MyTile#SmartTileWithLabel>
size_hint_y: None
height: "240dp"
<S>:
MDTextFieldRound:
pos_hint: {"center_x": .5, "center_y": .95}
normal_color : [1,1,1,.1]
color_active : [1,1,1,1]
size_hint: .8, .07
hint_text : 'Search a product...'
icon_left : 'magnify'
<JBSIDIS>
on_release: app.show_date_picker(root)
IconLeftWidget:
icon: "Photos/pro.jpg"
Screen:
name: "pantalla1"
MDToolbar:
id: tb1
title: "jbsidis"
pos_hint: {"top": 1}
md_bg_color: (.1, .1, .5, 1)
GridLayout:
cols: 2
padding: dp(20)
FloatLayout:
MDTextFieldRound:
id: search_field
pos_hint: {"center_x": .5, "center_y": .87}
hint_text : 'jbsidis...'
icon_left : 'magnify'
normal_color : (100, 100, 50, .5)
color_active : (255, 255, 255, 0)
on_text: app.search(root.ids.rvvv9,self.text)
BoxLayout:
id: m5
spacing: dp(10)
#padding: dp(20)
pos_hint: {"center_x": .5, "center_y": .32}
orientation: "vertical"
BoxLayout:
id: s_res9
size_hint_y: None
height: self.minimum_height
pos_hint: {"center_x": .5, "center_y": .4}
orientation: "vertical"
RecycleView:
id: rvvv9
key_viewclass: 'viewclass'
key_size: 'height'
RecycleBoxLayout:
padding: dp(10)
spacing: dp(5)
default_size: None, dp(75)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
MDToolbar:
id: success_screen_toolbar
title: "jbsidis"
pos_hint: {"top": 1}
right_action_items: [["progress-check", lambda: print(6)]]
MDBottomAppBar:
MDToolbar:
id: success_screen_bottomappbar
icon: "magnify"
on_action_button: app.eq(root.ids.search_field,True)
type: 'bottom'
mode: 'center'
#elevation: '8dp'
left_action_items: [["calendar-text", lambda x: print(6)], ["account-group", lambda x: print(6)]]
right_action_items: [["magnify", lambda x: app.eq(root.ids.search_field,True)], ["menu", lambda x: print(6)]]
'''
authors="jbsidis"
class JBSIDIS(OneLineIconListItem):
datex=StringProperty()
pass
class blanks1(BoxLayout):
pass
class S(FloatLayout):
pass
authors4="jbsidis"
books="""
Austen, Jane (72159) jbsidis
Du Bois, W. E. B. (William Edward Burghardt) (7364) jbsidis
Stowe, Harriet Beecher (7362) jbsidis
Vatsyayana (7343) jbsidis
Schopenhauer, Arthur (7317) jbsidis
Foote, Mary Hallock (7308) jbsidis
Bhide, Shivaram Parashuram (7256) jbsidis
Indrajit, Bhagavanlal (7256) jbsidis
"""
import time
import datetime
class Main(MDApp):
def build(self):
self.theme_cls.primary_palette = "Green"
return Builder.load_string(kv)
def get_date(self, date):
print(date)
t=str(date).split("-")
text="[b]"+str(t[-1])+"/"+str(t[1])+"/"+str(t[0])
year=time.strftime("%Y")
mes=time.strftime("%m")
dia=time.strftime("%d")
bx.text=text
afecha=str(t[-1])+"/"+str(t[1])+"/"+str(t[0])
return date
def show_date_picker(self,b):
from kivymd.uix.picker import MDDatePicker
global bx
bx=b
yearx=time.strftime("%Y")
mes=time.strftime("%m")
dia=time.strftime("%d")
current=time.strftime("%Y:%m:%d")
min_date = datetime.datetime.strptime(current, '%Y:%m:%d').date()
date_dialog = MDDatePicker(
callback=self.get_date,
min_date=min_date
)
date_dialog.open()
def all_pdfs(self):
return books.splitlines()
def eq(self,a,b):
a.focus=True
def search(self,a,b):
a.data=[]
for x in self.all_pdfs():
if b in str(x):
a.data.append(
{
"viewclass": "JBSIDIS",
"markup": True,
"text": "[b][size=33]jbsidis: [/b][/size]"+str(x)
}
)
pass
Main().run()
This is one of many ways you can do things using kivy and kivymd, jbsidis, everything is possible with Python and Kivy, here is the image, greetings from El Salvador:
I'm having trouble finding the solution in how to remove an expansion panel which inside of it it contains TwoLineAvatarListItem with a IconLeftWidget, and below that is a MDCard with two MDlabels for text. I've tried to use self.root.ids.remove_widget() but it does not do anything. I've tried many ways and have not found the solution. Here is the code please feel free to view. Thanks
kv. file
<Content>:
adaptive_height: True
#size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
TwoLineAvatarListItem:
text: "Message"
secondary_text: 'to: #gmail.com'
IconLeftWidget:
icon: 'email'
MDCard:
orientation: "vertical"
padding: "8dp"
size_hint: None, None
size: "280dp", "180dp"
pos_hint: {"center_x": .5, "center_y": .5}
MDLabel:
text: "Title"
theme_text_color: "Secondary"
size_hint_y: None
height: self.texture_size[1]
MDSeparator:
height: "1dp"
MDLabel:
text: "Body"
ScreenManager:
Screen:
id: messages
name: 'messages'
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: "Messages Center"
elevation:8
MDIconButton:
icon: 'arrow-left'
on_press: screen_manager.current = "main_app_screen"
theme_text_color: 'Custom'
md_bg_color: app.theme_cls.primary_color
ScrollView:
GridLayout:
cols: 1
size_hint_y: None
height: self.minimum_height
id: box
.py python file
class DemoApp(MDApp):
def on_start(self):
for i in range(10):
panel = MDExpansionPanel(
icon=f"{images_path}folder.png",
content=Content(),
panel_cls=MDExpansionPanelTwoLine(
text='',
secondary_text=str(i) + ' email: xxxxx#gmail.com',))
self.root.ids.box.add_widget(panel)
DemoApp().run()
<Content>:
[...]
MDCard:
[...]
MDRaisedButton:
text: "REMOVE"
on_release: app.remove(root)
[...]
class DemoApp(MDApp):
[...]
def remove(self, content):
self.root.ids.box.remove_widget(content.parent)