Closed Sahil-pixel closed 6 months ago
from kivy.lang import Builder
from kivymd.uix.label import MDLabel
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.segmentedbutton import (
MDSegmentedButton,
MDSegmentedButtonItem,
MDSegmentButtonLabel,
)
from kivymd.app import MDApp
KV = '''
MDScreen:
#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}
'''
class Example(MDApp):
def on_start(self):
for segment_type in ["large", ]:
self.root.ids.box.add_widget(
MDBoxLayout(
MDLabel(
text=f"Type '{segment_type}'",
adaptive_height=True,
bold=True,
pos_hint={"center_y": 0.5},
halign="center",
),
MDSegmentedButton(
MDSegmentedButtonItem(
MDSegmentButtonLabel(
text="Albums",
),
id="item",
),
MDSegmentedButtonItem(
MDSegmentButtonLabel(
text="Albums",
),
id="item2",
),
type=segment_type,
),
orientation="vertical",
spacing="12dp",
adaptive_height=True,
)
)
self.root.get_ids().item.bind(active=lambda *x: print(x))
self.root.get_ids().item2.bind(active=lambda *x: print(x))
def build(self):
return Builder.load_string(KV)
Example().run()
Screenshots
Add images to explain us this bug. Paste urls here.
Remove this section if no images here
Versions
OS: ubuntu
Python: v3.10.12
Kivy: v2.3.0
KivyMD: 2.0.1.dev0,