Search code examples
pythonkivykivy-languagekivymd

All the content in the MDDialog is overlapping


I tried adding adaptive_height to kv in gridlayout but it made the overlapping much worse. and tried using other layout but then placement becomes difficult.

.KV code

<Settings_Dialog>
    rows: 4
    adaptive_height: True
    
    MDLabel:
        text: 'App Settings'
        font_size: 15

    MDGridLayout:
        cols: 2
        rows: 1
        MDLabel:
            text: 'App Theme'
            font_size: 10
        ToggleButton:
            id: darklight
            text: {'normal':'LIGHT', 'down':'DARK'}[self.state]
            color: {'normal':[0,0,0], 'down':[1,1,1]}[self.state]
            background_color: {'normal':[1,1,1,1], 'down':[0,0,0,1]}[self.state]
            font_size: self.height * .6
            on_press: print(self.state)
            size_hint: 0.2, 0.8

    MDLabel:
        text: 'Plot Settings'
        font_size: 15

    MDGridLayout:
        rows: 3
        cols: 2

        MDLabel:
            text: "Plot Type"
            font_size: 10
        MDDropDownItem:
            id: g_type
            text: 'Candle'
            font_size: 10
            #current_item: 'Candle'
            on_release: root.plot_type.open()
        MDLabel:
            text: 'Plot Color'
            font_size: 10
        MDDropDownItem:
            id: g_color
            text: 'Default'
            font_size: 10
            #current_item: 'Default'
            on_release: root.plot_color.open()
        MDLabel:
            text: 'Volume'
            font_size: 10
        MDSwitch:
            active: True
            size_hint: 0.3,0.8

.py code part

class MainScreen(MDScreen):
    def settings(self):
        close_button = MDFlatButton(
            text = 'Close',
            font_size = 15,
            on_release = self.close_settings,
            opacity = 0.5
        )
        save_button = MDFlatButton(
            text = 'Save Changes',
            font_size = 15,
            on_release = self.savee,
            opacity = 0.5
        )
        self.settings = MDDialog(
                    title = 'Settings',
                    auto_dismiss = False,
                    type = 'custom',
                    content_cls = Settings_Dialog(),
                    buttons = [save_button, close_button]
        )
        self.settings.open()
        
    def close_settings(self, obj):
        self.settings.dismiss()
    
    def savee(self, obj):
        self.settings.dismiss()

class Settings_Dialog(MDGridLayout):
    ##and have a few function in here but they don't do anything with size...

So, here basically MainScreen is my main screen then on a button press it calls the dialog.

image of the issue you can see the close and switch overlapping

SOLUTION:

Just put adaptive_height: True in all the objects

image now the overlapping is gone.


Solution

  • Just put adaptive_height: True in all the objects