0
我正在使用Python的第二版Kivy-Interactive Applications and Games。矩形應該是灰色的,但它們只是白色的。我從Git集線器下載了一些代碼,它應該返回對角紅線,但它的白色也是。任何幫助將不勝感激,我可能會錯過簡單的東西。使用kivy,爲什麼矩形不會改變顏色?
# File name: color.py
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.lang import Builder
Builder.load_string("""
<GridLayout>:
cols: 2
Label:
color: 0.5, 0.5, 0.5, 1
canvas:
Rectangle:
pos: self.x + 10, self.y + 10
size: self.width - 20, self.height - 20
Widget:
canvas:
Rectangle:
pos: self.x + 10, self.y + 10
size: self.width - 20, self.height - 20
""")
class LabelApp(App):
def build(self):
return GridLayout()
if __name__ == '__main__':
LabelApp().run()
我知道這會工作。我只是複製了這本書的內容。我只是小寫的顏色是新東西,我做錯了。 –
@BradleyRay好吧,你有它。那是錯的。正如你所說,可能是簡單的:) – EL3PHANTEN
感謝您的幫助:) –