Python 更改画布中的背景色

Python 更改画布中的背景色,python,canvas,background,kivy,screen,Python,Canvas,Background,Kivy,Screen,我正在尝试将背景色更改为白色或删除第一页屏幕前的黑屏。我的第二个和第三个屏幕背景显示,但第一个屏幕前面有一个黑屏。在单击下一个屏幕之前,屏幕似乎阻止了我要显示的内容。我不知道如何把黑屏放在我的屏幕后面或删除它 屏蔽电压(千伏) <Login>: BoxLayout: canvas.before: Color: rgb: 255, 255, 255 Rectangle:

我正在尝试将背景色更改为白色或删除第一页屏幕前的黑屏。我的第二个和第三个屏幕背景显示,但第一个屏幕前面有一个黑屏。在单击下一个屏幕之前,屏幕似乎阻止了我要显示的内容。我不知道如何把黑屏放在我的屏幕后面或删除它

屏蔽电压(千伏)

<Login>:    
 BoxLayout:
      canvas.before:
           Color:
                rgb: 255, 255, 255
           Rectangle:
                pos: self.pos
                size: self.size
      orientation: 'vertical'
      size: root.size
      padding: [150, 25, 150, 25]
      spacing: 50

      Image:
           source:'NextStep.Final.png'
           texture: self.texture
           size: 0, 100
           size_hint: 1, None

      Label:         
           text: 'Welcome to A.M.B.L.E'
           font_size: 32
           color: 0, 0, 0, 1



      Label:         
           text: 'Welcome to A.M.B.L.E'
           font_size: 32
           color: 0, 0, 0, 1




      BoxLayout:
           orientation: 'vertical'
           size_hint: 1, 10

           Label:
                text: 'Username:'
                font_size: 18
                halign: 'left'
                text_size: root.width-20, 20
                color: 0, 0, 0, 1

           TextInput:
               id: login
               multiline:False
               font_size: 28



           BoxLayout:
               orientation: 'vertical'
               size_hint: 1, 10

           Label:
                text: 'Password:'
                halign: 'left'
                font_size: 18
                text_size: root.width-20, 20
                color: 0, 0, 0, 1

          TextInput:
               id: password
               multiline:False
               password:True
               font_size: 28

          Button:
              text: 'Login'
              font_size: 24
              size_hint: 1, 5
              color: 1, 1, 1, 1
              background_color: 0, 0, 0, 1


              on_press: root.manager.current = 'Connected'


<Connected>:
     canvas.before:
          Color:
               rgb: 1, 1, 1 
          Rectangle:
               pos: self.pos
               size: self.size
     BoxLayout:

      orientation: 'vertical'
      size: root.size
      padding: [150, 25, 150, 25]
      spacing: 50

      Image:
           source:'NextStep.Final.png'
           texture: self.texture
           size: 0, 100
           size_hint: 1, None

      Label:         
           text: 'Welcome to A.M.B.L.E'
           font_size: 32
           color: 0, 0, 0, 1




      Button:
           text:'View Patient'
           font_size: 18
           color: 1, 1, 1, 1
           background_color: 0, 0, 0, 1
           on_press: root.manager.current = 'Patient'





      Button:           
           text:'Patient Goals'
           font_size: 18
           color: 1, 1, 1, 1
           background_color: 0, 0, 0, 1



      Button:
           text:'Patient Progress'
           font_size: 18
           color: 1, 1, 1, 1
           background_color: 0, 0, 0, 1


      Button:
           text:'Help'
           font_size: 18
           color: 1, 1, 1, 1
           background_color: 0, 0, 0, 1


<Patient>:
     canvas.before:
          Color:
               rgb: 1, 1, 1 
          Rectangle:
               pos: self.pos
               size: self.size
     BoxLayout:

      orientation: 'vertical'
      size: root.size
      padding: [150, 25, 150, 25]
      spacing: 50

      Image:
           source:'NextStep.Final.png'
           texture: self.texture
           size: 0, 100
           size_hint: 1, None

      Label:         
           text: 'Welcome to A.M.B.L.E'
           font_size: 32
           color: 0, 0, 0, 1



<Manager>:
     id: screen_manager 

     login: login
     connected: connected 
     patient: patient 

     Login:
         id: login 
         name: 'Login'
         manager: screen_manager 

     Connected:
         id: connected
         name: 'Connected'
         manager: screen_manager 

     Patient:
         id: patient
         name: 'Patient'
         manager: screen_manager 

在重新格式化了您的
kv
文件后,它似乎对我来说很好。你能添加一个屏幕截图来显示问题是什么吗?@RanyeMclendon:将你的kv文件从
screen.kv
重命名为
screens.kv
,它在重新格式化后工作。非常感谢。
from kivy.app import App 
from kivy.uix.screenmanager import ScreenManager, Screen, 
SlideTransition 
from kivy.properties import ObjectProperty
from kivy.uix.image import Image
from kivy.graphics import Color 
from kivy.graphics import Rectangle 
from kivy.core.window import Window 

import os

from connected import Connected


class Login(Screen):
    pass

class Connected(Screen):
    pass


class Patient(Screen):
    pass 


class Manager(ScreenManager):

    patient = ObjectProperty(None)
    connected = ObjectProperty(None)
    login = ObjectProperty(None)

class ScreensApp(App):

    def build(self):

        m = Manager(transition=SlideTransition())   
        return m



if __name__ == '__main__':
    ScreensApp().run()