更改画布中的背景颜色

时间:2018-07-24 16:13:44

标签: python canvas background kivy screen

我正在尝试将背景颜色更改为白色,或者删除第一页屏幕前的黑色屏幕。我的第二个和第三个屏幕背景显示,但是第一个背景前面有黑屏。似乎该屏幕阻止了我要显示的内容,直到我单击到下一个屏幕为止。我不确定如何将黑屏放在屏幕背面或将其删除。

screen.kv

subsamples

patient.py

<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 

0 个答案:

没有答案