以下代碼有什么問題?# Program to Show how to create a switch# import kivy moduleimport kivy# base Class of your App inherits from the App class.# app:always refers to the instance of your applicationfrom kivy.app import App# this restrict the kivy version i.e# below this kivy version you cannot# use the app or softwarekivy.require('1.9.0')# Builder is used when .kv file is# to be used in .py filefrom kivy.lang import Builder# The screen manager is a widget# dedicated to managing multiple screens for your application.from kivy.uix.screenmanager import ScreenManager, Screen# You can create your kv code in the Python fileBuilder.load_string(""" <ScreenOne>: BoxLayout: canvas.before: Color: rgba: (.4, .6, 9, 1) #(0,0,0,1) Rectangle: size: self.size pos: self.pos canvas: Color: rgba: (1, 1, 1,1) RoundedRectangle: size : self.width/2, self.height/3 pos : self.center_x - self.width/4 , self.center_y - self.height/6 radius: [(40, 40), (40, 40), (40, 40), (40, 40)] Button: text: "Go to Screen 2" background_color : 0, 0, 1, 1 on_press: # You can define the duration of the change # and the direction of the slide root.manager.transition.direction = 'left' root.manager.transition.duration = 1 root.manager.current = 'screen_two' 我是 kivy 的新手,在網上獲得了這段代碼,效果很好。我現在試圖通過在其中放置一些畫布和形狀來更改它,但出現錯誤: AttributeError: 'kivy.graphics.context_instructions.Color' object has no attribute 'fbind'這是什么意思,我怎樣才能再次改變它以實現我的目標,即放置我的 2 個矩形并在它們上面放置按鈕?
1 回答

LEATH
TA貢獻1936條經驗 獲得超7個贊
假設您正確復制并粘貼了代碼,但縮進是錯誤的,您已將 Color 指令放在子小部件級別,而不是縮進到canvas.before:
. 這很可能導致您的錯誤。
添加回答
舉報
0/150
提交
取消