Kivy Rules and Properties
当我在 ModuleLayout 中应用 ModuleMaker 规则时,我试图指定 InputMaker 按钮的文本。但是,当我运行程序时,没有显示任何文本(即"Yo")。来源似乎工作正常,但文本不是。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | <InputMaker@Button>: text: self.text pos: self.pos size: self.size background_normal:'./images/modone.png' <ModuleMaker>: size: 150, 150 source: self.source text: self.text canvas: Ellipse: pos: self.pos size: self.size source: self.source InputMaker: id: btnone text: self.text pos: self.parent.pos <ModuleLayout>: moduleone: one moduletwo: two modulethree: three ModuleMaker: id: one center_y: root.center_y x: root.x +300 source: './images/modone.png' text:"YO" ModuleMaker: id: two center_y: root.center_y x: root.x+400 source: './images/modtwo.png' ModuleMaker: id: three center_y: root.center_y x: root.x+500 source: './images/modthree.png' |
当您真的想绑定到 root.text 时,您的 InputMaker 规则会引用 self.text。