community icon indicating copy to clipboard operation
community copied to clipboard

White Background during SlideTransition

Open todestoast opened this issue 4 years ago • 2 comments

The Problem output

As seen above during the transitions the background suddenly becomes white.

What have I tried?

  • set background color for both Screens
  • set clearcolor for ScreenManager
  • set Background Color for ScreenManager
  • also tested with native kivy elements (no KivyMD) - this has no effect

My Code md.kv:

#:import C kivy.utils.get_color_from_hex
#: import ScreenManager kivy.uix.screenmanager.ScreenManager
<MainWindow>:
    name: "main"
    canvas:
        Color:
            rgba: C('#18294a')
        Rectangle:
            pos: self.pos
            size: self.size

    FloatLayout:
        Label:
            text:"Connect to this computer"
            font_size: 20
            color: C('#ffffff')
            pos_hint: {"x":.08, "y":.3}
            size_hint: 0.35, 0.15

        Label:
            text:"Connect to another computer"
            font_size: 20
            color: C('#ffffff')
            pos_hint: {"x":.58, "y":.3}
            size_hint: 0.35, 0.15

       MDIconButton:
            ripple_scale: 0
            #md_bg_color: app.theme_cls.primary_color
            theme_text_color: "Custom"
            text_color: C('#ffffff') 
            icon: "arrow-down-bold"
            user_font_size:"200sp"
            #md_bg_color: C('#ffffff') 
            pos_hint:{"x":0.1,"y":0.4}
            size_hint: .3, .3
            on_release:
                root.manager.transition.direction = "down"
                root.connectTo()

                
        MDIconButton:
            ripple_scale: 0
            #md_bg_color: app.theme_cls.primary_color
            theme_text_color: "Custom"
            text_color: C('#ffffff') 
            icon: "arrow-up-bold"
            user_font_size:"200sp"
            #md_bg_color: C('#ffffff') 
            pos_hint:{"x":0.6,"y":0.4}
            size_hint: .3, .3
            on_release:
                root.manager.transition.direction = "up"
                root.connectTo()

<ConnectToWindow>:
    name: "connectTo"
    canvas:
        Color:
            rgba: C('#18294a')
        Rectangle:
            pos: self.pos
            size: self.size

ScreenManager:
    clearcolor: C('#18294a')
    canvas:
        Color:
            rgba: C('#18294a')
        Rectangle:
            size: self.size
            pos: self.pos
    id: sm

main.py:

sm = ScreenManager(transition=SlideTransition())

class MainWindow(Screen):
    def connectTo(self):
        sm.current = "connectTo"


    def establishConnect(self):
        sm.current = "main"

class MyMainApp(MDApp):
    def build(self):
        kv = Builder.load_file("md.kv")
        screens = [MainWindow(name="main"),ConnectToWindow(name="connectTo")]
        for screen in screens:
            sm.add_widget(screen)

        sm.current = "main"
        return sm



if __name__ == "__main__":
    MyMainApp().run()

todestoast avatar Jun 12 '20 00:06 todestoast

I have the same problem, but I guess it is supposed to work like this, the slide transition is not seamless.

You can use the CardTransition, which is seamless, but I found that WipeTransition is more elegant.

neo-mashiro avatar Sep 17 '20 10:09 neo-mashiro

Hi todestoast, Try this:

#:import C kivy.utils.get_color_from_hex
#:import ScreenManager kivy.uix.screenmanager.ScreenManager

  <MainWindow>:
      name: "main"
      FloatLayout:
          canvas:
                  Color:
                      rgba: C('#18294a')
                  Rectangle:
                      pos: self.pos
                      size: self.size

.....

Block canvas should be after FloatLayout:

Andrzej

andrzejs avatar Apr 09 '22 18:04 andrzejs

I solved it by writing the code like this

from kivy.core.window import Window

Window.clearcolor = (1, 0, 0, 1)

https://kivy.org/doc/stable/api-kivy.core.window.html#kivy.core.window.WindowBase.clearcolor

Serelue avatar Apr 02 '23 04:04 Serelue

👋 We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project.

If you're having trouble installing Kivy, make sure to check out the installation docs for Windows, Linux and macOS.

Let us know if this comment was made in error, and we'll be happy to reopen the issue.

github-actions[bot] avatar Nov 02 '23 14:11 github-actions[bot]