亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AttributeError: 'kivy.graphics.context_instruc

AttributeError: 'kivy.graphics.context_instruc

一只名叫tom的貓 2023-05-23 15:33:29
以下代碼有什么問題?# 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:. 這很可能導致您的錯誤。



查看完整回答
反對 回復 2023-05-23
  • 1 回答
  • 0 關注
  • 133 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號