简体   繁体   中英

Kivy FloatLayout in multiple screens

The FLoatLayout in kivy seems to restricted to only one screen per time. I want to use multiple screens and apply FloatLayout on all of them.

What I have tried:

  1. I know I can separate all the screens into different kivy and python files then combine them, but I don't want to because of ease of use.
  2. I tried allowing my classes (Screens) to inherit from both screen and FloatLayout, but apparently the ScreenManager does not accept 'non-screen inputs'
  3. I am using kivy Language, (not python) so I can not just assign widgets to the FloatLayout inside a window class then return it.

ps. The reason I want to use FloatLayout is to avoid overlapping widgets. I wouldn't mind using another layout if it produces a similar result.

You can add another layout in your screen like this (in the kv part of the code):

    ScreenManager:
        id: screens
        Screen:
            name: "main"
            id: main
            BoxLayout:
                id: main_box

You can do something similar in the python part of the code by using:

main_box = BoxLayout()
self.ids.main.add_widget(main_box)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM