为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 Kivy/Python 的另一个屏幕中从一个屏幕引用 TextInput?

如何在 Kivy/Python 的另一个屏幕中从一个屏幕引用 TextInput?

慕桂英4014372 2021-06-06 08:44:19
我正在尝试制作一个可以计算圆锥体体积的应用程序(到目前为止)。我有一个名为 ConeVolumeScreen 的屏幕,它有两个 TextInput 小部件。<ConeVolumeScreen>:    BoxLayout:        orientation: ...        padding: ...        spacing: ...        Label:            text: 'Radius:'        TextInput:            id: cone_vol_radius            multiline: False            input_type: 'number'        Label:            text: 'Height:'        TextInput:            id: cone_vol_height            multiline: False            input_type: 'number'        Button:            text: 'Solve'            on_release: app.root.changeScreen('solve cone volume')               一个人应该在这两个小部件中输入圆锥的半径和高度。然后这个人可以点击一个按钮进入下一个名为 SolveConeVolumeScreen 的屏幕。在此屏幕中有一个标签,应打印该人指定的锥体体积。<SolveConeVolumeScreen>:    BoxLayout:        orientation: ...        padding: ...        spacing: ...        Label:            text: app.getConeVolume(cone_vol_radius, cone_vol_height)getConeVolume() 是这里的一个方法class CalculatorRoot(BoxLayout):    def __init__(self, **kwargs):        super(CalculatorRoot, self).__init__(**kwargs)        self.screen_list = []    def changeScreen(self, next_screen):        if self.ids.calc_screen_manager.current not in self.screen_list:            self.screen_list.append(self.ids.calc_screen_manager.current)        if next_screen == 'volume':            self.ids.calc_screen_manager.current = 'volume_screen'        elif next_screen == 'area_screen':            self.ids.calc_screen_manager.current = 'area_screen'        elif next_screen == 'surface area':            self.ids.calc_screen_manager.current = 'surfarea_screen'但是错误说没有定义cone_vol_radius。 ... 128:        spacing: min(root.width, root.height) * .02 129:        Label:130:文本:app.getConeVolume(cone_vol_radius,cone_vol_height)131:132:: ... BuilderException:解析器:文件“/Users/fayzulloh/Desktop/Calculator App/calculator.kv”,第130行:... 128:间距: min(root.width, root.height) * .02 129: 标签: 130: text: app.getConeVolume(cone_vol_radius, cone_vol_height) 131: 132:: ... NameError: name 'cone_vol_radius' 未定义请帮忙。我真的很感激任何建议。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 164 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号