You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am adding and removing widgets MDSegmentedButtonItem by button press
but outcome is not as expected .
MDSegmentedButtonItem increases its size , see video
Code and Logs
from kivymd.uix.label import MDLabel
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.screen import MDScreen
from kivymd.uix.segmentedbutton import (
MDSegmentedButton,
MDSegmentedButtonItem,
MDSegmentButtonLabel,
)
from kivymd.app import MDApp
KV = '''
<MS>:
md_bg_color: self.theme_cls.backgroundColor
MDBoxLayout:
id: box
orientation: "vertical"
size_hint_x: .7
adaptive_height: True
spacing: "24dp"
pos_hint: {"center_x": .5, "center_y": .5}
MDSegmentedButton:
id:sb
Button:
text:'Add Items'
size_hint:None,None
pos_hint:{'x':0,'y':0}
size:'80dp','48dp'
on_release:root._add()
Button:
text:'Remove Items'
size_hint:None,None
size:'80dp','48dp'
pos_hint:{'right':1,'y':0}
on_release:root._remove()
'''
Builder.load_string(KV)
class MS(MDScreen):
items=[]
def _add(self):
self.items=[]
for i in range(4):
item=MDSegmentedButtonItem(MDSegmentButtonLabel(text="Albums",),on_active=lambda x:print(x),)
self.items.append(item)
self.ids.sb.add_widget(item)
def _remove(self):
print('hello')
for item in self.items:
print(item)
self.ids.sb.ids.container.remove_widget(item)
class Example(MDApp):
def build(self):
return MS()
Example().run()
Screenshots
Add images to explain u
Screencast.from.23-04-24.04-04-26.PM.IST.mp4
Versions
OS: ubuntu
Python: 3.10
Kivy: 2.3.0
KivyMD: 2.0.1dev
The text was updated successfully, but these errors were encountered:
I am adding and removing widgets MDSegmentedButtonItem by button press
but outcome is not as expected .
MDSegmentedButtonItem increases its size , see video
Code and Logs
Screenshots
Add images to explain u
Screencast.from.23-04-24.04-04-26.PM.IST.mp4
Versions
The text was updated successfully, but these errors were encountered: