例如,下面是代码
.py文件
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
class ScreenOne(Screen):
pass
class WindowManager(ScreenManager):
pass
kv = Builder.load_file("testing.kv")
class ScreenApp(App):
def build(self):
return kv
if __name__ == '__main__':
ScreenApp().run()
.kv恶意
WindowManager:
ScreenOne:
<ScreenOne>:
GridLayout:
size: root.height, root.width
rows: 2
Button:
text: "Break this button into 3 smaller buttons"
Label:
text: ""
当按钮被点击的时候,我想把按钮分成3个小按钮。你能帮我做一个on_release命令来做吗?
1条答案
按热度按时间fjnneemd1#
然后在
ScreenOne
类中创建一个名为break_into_three
的函数,并将其定义如下:我没有一个工作的Kivy环境来测试这一点,但我想你明白了。