nathan
nathan

Reputation: 44

MDLabel multi line overlaps other widgets

newevent.kv

MDTextField:
            id: remarks
            mode: "outlined"
            multiline: True

main.kv

MDScreen:
    name: 'main'
    md_bg_color: "#ffffff"
    MDNavigationLayout:
        MDScreenManager:

            MDScreen:

                MDTopAppBar:
                    theme_bg_color: "Custom"
                    md_bg_color: 255/255, 242/255, 0, 1
                    type: "small"
                    pos_hint: {"top":1}
                    size_hint_x: 1
                    MDTopAppBarLeadingButtonContainer:
                        MDActionTopAppBarButton:
                            icon: "menu"
                            on_release: nav_drawer.set_state("toggle")
                    MDTopAppBarTitle:
                        text: "Cargo Tracker"
                        
                    MDTopAppBarTrailingButtonContainer:
                        MDActionTopAppBarButton:
                            icon: "magnify"

                ScrollView:
                    do_scroll_x: False
                    do_scroll_y: True
                    size_hint_y: .9
                    GridLayout:
                        id: add_event
                        cols: 1
                        padding: 15,10
                        spacing: 15,10
                        size_hint_y: None
                        height: self.minimum_height

main.py

 def add_main_widgets(self):
        grid = self.sm.get_screen('main').ids.add_event
        remarks = self.sm.get_screen('newevent').ids.remarks
        barcode = self.sm.get_screen('newevent').ids.scanned_barcode
        status = self.root.get_screen('newevent').ids.bt1
        event_buttons = self.sm.get_screen('main').ids.bottom_nav
        self.widget_count += 1

        # Parent
        parent = MDCard(
            style='elevated',
            padding="4dp",
            size_hint_y=None,

        )

        # Creating child widgets
        progress_bar = MDFloatLayout(
            id="bar",
            size_hint=(.01, .95),
            pos_hint={"center_x": .02, "center_y": .5},
            md_bg_color="yellow"
        )
        relative = MDRelativeLayout()

        anchor_status = AnchorLayout(
            anchor_x='right',
            anchor_y='top',
            size_hint=(None, None),
            size=(120, 50),  # Adjust the size as needed
            pos_hint={'right': 1, 'top': 1}
        )
        status_label = MDLabel(
            text=status.text,
            theme_font_name="Custom",
            font_name="f2icons/status.ttf",
            theme_text_color="Custom",
            text_color="green",
            adaptive_size=True,

        )
        anchor_status.add_widget(status_label)

        scanner_label = MDLabel(
            text=f"[{self.widget_count} of {self.widget_count}]: {barcode.text}",
            adaptive_size=True,
            pos=("12dp", "53dp"),
            bold=True

        )
        remarks_text = MDLabel(
            text="Remarks:",
            bold=True,
            font_style="Body",
            role="medium",
            theme_text_color="Custom",
            text_color="#666666",
            adaptive_size=True,
            pos=("12dp", "39dp"),

        )

        remarks_label = MDLabel(
            text=remarks.text,
            font_style="Body",
            role="small",
            pos=("12dp", "23dp"),
            adaptive_height = True,


        )

        location_status_text = MDLabel(
            text="Status: Ready to transmit.",
            font_style="Body",
            bold=True,
            role="small",
            theme_text_color="Custom",
            text_color="#666666",
            adaptive_size=True,
            pos=("12dp", "5dp")

        )
        relative.add_widget(progress_bar)
        relative.add_widget(anchor_status)
        relative.add_widget(scanner_label)
        relative.add_widget(remarks_text)
        relative.add_widget(remarks_label)
        relative.add_widget(location_status_text)
        parent.add_widget(relative)
        grid.add_widget(parent)

On my newevent.kv it has a textfield remarks so multiline should be enabled however when i try to display it overlaps other widgets.

Output:Overlapping text

Expected output:Not overlapping

Can someone help me solving this problem. Thanks!

Upvotes: 0

Views: 26

Answers (0)

Related Questions