久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    1. <small id='dTOHr'></small><noframes id='dTOHr'>

      <i id='dTOHr'><tr id='dTOHr'><dt id='dTOHr'><q id='dTOHr'><span id='dTOHr'><b id='dTOHr'><form id='dTOHr'><ins id='dTOHr'></ins><ul id='dTOHr'></ul><sub id='dTOHr'></sub></form><legend id='dTOHr'></legend><bdo id='dTOHr'><pre id='dTOHr'><center id='dTOHr'></center></pre></bdo></b><th id='dTOHr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='dTOHr'><tfoot id='dTOHr'></tfoot><dl id='dTOHr'><fieldset id='dTOHr'></fieldset></dl></div>
    2. <tfoot id='dTOHr'></tfoot>
    3. <legend id='dTOHr'><style id='dTOHr'><dir id='dTOHr'><q id='dTOHr'></q></dir></style></legend>

        <bdo id='dTOHr'></bdo><ul id='dTOHr'></ul>

        如何在 Kivy/Python 的另一個屏幕中從一個屏幕引用

        How to ref a TextInput from one screen in another screen in Kivy/Python?(如何在 Kivy/Python 的另一個屏幕中從一個屏幕引用 TextInput?)
            <tfoot id='S01PK'></tfoot>
            • <small id='S01PK'></small><noframes id='S01PK'>

                <legend id='S01PK'><style id='S01PK'><dir id='S01PK'><q id='S01PK'></q></dir></style></legend>

                  <bdo id='S01PK'></bdo><ul id='S01PK'></ul>
                  <i id='S01PK'><tr id='S01PK'><dt id='S01PK'><q id='S01PK'><span id='S01PK'><b id='S01PK'><form id='S01PK'><ins id='S01PK'></ins><ul id='S01PK'></ul><sub id='S01PK'></sub></form><legend id='S01PK'></legend><bdo id='S01PK'><pre id='S01PK'><center id='S01PK'></center></pre></bdo></b><th id='S01PK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='S01PK'><tfoot id='S01PK'></tfoot><dl id='S01PK'><fieldset id='S01PK'></fieldset></dl></div>
                    <tbody id='S01PK'></tbody>
                  本文介紹了如何在 Kivy/Python 的另一個屏幕中從一個屏幕引用 TextInput?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試制作一個可以計算圓錐體積的應用程序(到目前為止).我有一個名為 ConeVolumeScreen 的屏幕,它有兩個 TextInput 小部件.

                  <ConeVolumeScreen>:盒子布局:方向: ...填充:...間距:...標簽:文本:'半徑:'文本輸入:編號:cone_vol_radius多行:假輸入類型:數字"標簽:文字:'身高:'文本輸入:編號:cone_vol_height多行:假輸入類型:數字"按鈕:文字:'解決'on_release: app.root.changeScreen('求解錐體體積')

                  一個人應該在這兩個小部件中輸入圓錐的半徑和高度.然后該人可以單擊一個按鈕以轉到名為 SolveConeVolumeScreen 的下一個屏幕.在此屏幕中,有一個標簽應該打印人員指定的錐體的體積.

                  <SolveConeVolumeScreen>:盒子布局:方向: ...填充:...間距:...標簽:文本:app.getConeVolume(cone_vol_radius, cone_vol_height)

                  getConeVolume() 是這里的一個方法

                  類 CalculatorRoot(BoxLayout):def __init__(self, **kwargs):super(CalculatorRoot, self).__init__(**kwargs)self.screen_list = []def changeScreen(self, next_screen):如果 self.ids.calc_screen_manager.current 不在 self.screen_list 中:self.screen_list.append(self.ids.calc_screen_manager.current)如果 next_screen == '音量':self.ids.calc_screen_manager.current = 'volume_screen'elif next_screen == 'area_screen':self.ids.calc_screen_manager.current = 'area_screen'elif next_screen == '表面積':self.ids.calc_screen_manager.current = 'surfarea_screen'elif next_screen == '圓錐體積':self.ids.calc_screen_manager.current = 'coneVolume_screen'elif next_screen == '求解錐體體積':self.ids.calc_screen_manager.current = 'solveConeVolume_screen'elif next_screen == '基于矩形的金字塔體積':self.ids.calc_screen_manager.current = 'rectPyramidVolume_screen'def onBackButton(self):如果 self.screen_list:self.ids.calc_screen_manager.current = self.screen_list.pop()返回真返回假類計算器應用程序(應用程序):def __init__(self, **kwargs):super(CalculatorApp, self).__init__(**kwargs)Window.bind(on_keyboard=self.onBackButton)def onBackButton(self, window, key, *args):如果鍵 == 27:返回 self.root.onBackButton()定義構建(自我):返回計算器根()def getConeVolume(self, r, h):first_step = 'π * ' + str(r) + '^2 * ' + str(h) + '/3
                  'rr = 圓形(r * r, 2)second_step = 'π * ' + str(rr) + ' * ' + str(h) + '/3
                  'rh = 圓形(rr * h, 2)第三步 = 'π * ' + str(rh) + '/3
                  'pirh = round(pi * rh, 2)第四步 = str(pirh) + '/3
                  '結果=圓形(pi * rh,2)final_step = '答案是' + str(result) + '.'事情 = first_step + second_step + third_step + Fourth_step + final_step退貨

                  但是錯誤說沒有定義cone_vol_radius.

                  <代碼> ...128: 間距: min(root.width, root.height) * .02129:標簽:

                  <塊引用><塊引用>

                  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) * .02129:標簽:130:文本:app.getConeVolume(cone_vol_radius,cone_vol_height)131:132::...NameError: name 'cone_vol_radius' 未定義

                  請幫忙.我真的很感激任何建議.

                  這是我的屏幕管理器

                  <CalculatorRoot>:方向:垂直"屏幕管理器:id: calc_screen_manager開始屏幕:名稱:'start_screen'卷屏:id:volume_screen名稱:'volume_screen'區域屏幕:id: area_screen名稱:'area_screen'表面積屏幕:id: surfarea_screen名稱:surfarea_screen"錐體屏幕:id:coneVolume_screen名稱:'coneVolume_screen'SolveConeVolumeScreen:id:solveConeVolume_screen名稱:'solveConeVolume_screen'RectPyramidVolumeScreen:id: rectPyramidVolume_screen名稱:'rectPyramidVolume_screen'

                  解決方案

                  錯誤

                  應用程序中有幾個錯誤.

                  NameError - 解決方案

                  root.ids.ids.coneVolume_screen.ids. 添加到參數中.

                  屬性錯誤

                  解決 NameError 后,會發生 AttributeError.AttributeError: 'NoneType' 對象沒有屬性 'ids'.這是因為內部 id 尚不可用.

                  I'm trying to make an app that can calculate the volume of a cone(so far). I have a screen named ConeVolumeScreen that has two TextInput widgets.

                  <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')               
                  

                  A person is supposed to enter the radius and height of the cone into these two widgets. Then the person can click on a button to go to the next screen named SolveConeVolumeScreen. In this screen there is a Label that should print the volume of the cone that the person specified.

                  <SolveConeVolumeScreen>:
                      BoxLayout:
                          orientation: ...
                          padding: ...
                          spacing: ...
                          Label:
                              text: app.getConeVolume(cone_vol_radius, cone_vol_height)
                  

                  getConeVolume() is a method over here

                  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'
                          elif next_screen == 'cone volume':
                              self.ids.calc_screen_manager.current = 'coneVolume_screen'
                          elif next_screen == 'solve cone volume':
                              self.ids.calc_screen_manager.current = 'solveConeVolume_screen'
                          elif next_screen == 'rectangular based pyramid volume':
                              self.ids.calc_screen_manager.current = 'rectPyramidVolume_screen'
                  
                      def onBackButton(self):
                          if self.screen_list:
                              self.ids.calc_screen_manager.current = self.screen_list.pop()
                              return True
                          return False
                  
                  
                  
                  class CalculatorApp(App):
                      def __init__(self, **kwargs):
                          super(CalculatorApp, self).__init__(**kwargs)
                          Window.bind(on_keyboard=self.onBackButton)
                  
                      def onBackButton(self, window, key, *args):
                          if key == 27:
                              return self.root.onBackButton()
                  
                      def build(self):
                          return CalculatorRoot()
                  
                      def getConeVolume(self, r, h):
                          first_step = 'π * ' + str(r) + '^2 * ' + str(h) + ' / 3
                  '
                          rr = round(r * r, 2)
                          second_step = 'π * ' + str(rr) + ' * ' + str(h) + ' / 3
                  '
                          rh = round(rr * h, 2)
                          third_step = 'π * ' + str(rh) + ' / 3
                  '
                          pirh = round(pi * rh, 2)
                          fourth_step = str(pirh) + ' / 3
                  '
                          result = round(pi * rh, 2)
                          final_step = 'The answer is ' + str(result) + '.'
                          thing = first_step + second_step + third_step + fourth_step + final_step
                          return thing
                  

                  But the error says that cone_vol_radius is not defined.

                   ...
                   128:        spacing: min(root.width, root.height) * .02
                   129:        Label:
                  

                  130: text: app.getConeVolume(cone_vol_radius, cone_vol_height) 131: 132:: ... BuilderException: Parser: File "/Users/fayzulloh/Desktop/Calculator App/calculator.kv", line 130: ... 128: spacing: min(root.width, root.height) * .02 129: Label: 130: text: app.getConeVolume(cone_vol_radius, cone_vol_height) 131: 132:: ... NameError: name 'cone_vol_radius' is not defined

                  please help. I would really appreciate any advice.

                  here is my screenmanager

                  <CalculatorRoot>:
                      orientation: "vertical"
                  
                      ScreenManager:
                          id: calc_screen_manager
                          StartScreen:
                              name: 'start_screen'
                          VolumeScreen:
                              id: volume_screen
                              name: 'volume_screen'
                          AreaScreen:
                              id: area_screen
                              name: 'area_screen'
                          SurfaceAreaScreen:
                              id: surfarea_screen
                              name: 'surfarea_screen'
                          ConeVolumeScreen:
                              id: coneVolume_screen
                              name: 'coneVolume_screen'
                          SolveConeVolumeScreen:
                              id: solveConeVolume_screen
                              name: 'solveConeVolume_screen'
                          RectPyramidVolumeScreen:
                              id: rectPyramidVolume_screen
                              name: 'rectPyramidVolume_screen'
                  

                  解決方案

                  Errors

                  There are a couple of errors in the application.

                  NameError - Solution

                  Add root.ids.ids.coneVolume_screen.ids. to the arguments.

                  AttributeError

                  After solving the NameError, an AttributeError will occurred. AttributeError: 'NoneType' object has no attribute 'ids'. This is because inner ids are not available yet.

                  Kivy Language ? ids

                  Note that the outermost widget applies the kv rules to all its inner widgets before any other rules are applied. This means if an inner widget contains ids, these ids may not be available during the inner widget’s __init__ function.

                  AttributeError: ids - Solutions

                  1. Give an id to the Label e.g. id: result
                  2. Add an on_pre_enter event to invoke getConeVolume() method.
                  3. Replace TextInput object with TextInput's text i.e. replace cone_vol_radius and cone_vol_height with cone_vol_radius.text and cone_vol_height.text respectively.
                  4. Add int() function to convert TextInput's text/string to integer.

                  Snippet

                  <SolveConeVolumeScreen>:
                      on_pre_enter:
                          root.ids.result.text = app.getConeVolume(int(app.root.ids.coneVolume_screen.ids.cone_vol_radius.text), int(app.root.ids.coneVolume_screen.ids.cone_vol_height.text))
                  
                      BoxLayout:
                          orientation: 'vertical'
                          Label:
                              id: result
                  

                  Output

                  這篇關于如何在 Kivy/Python 的另一個屏幕中從一個屏幕引用 TextInput?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

                • <small id='TbYPg'></small><noframes id='TbYPg'>

                  <legend id='TbYPg'><style id='TbYPg'><dir id='TbYPg'><q id='TbYPg'></q></dir></style></legend>
                    <bdo id='TbYPg'></bdo><ul id='TbYPg'></ul>
                    <tfoot id='TbYPg'></tfoot>
                      <tbody id='TbYPg'></tbody>

                      <i id='TbYPg'><tr id='TbYPg'><dt id='TbYPg'><q id='TbYPg'><span id='TbYPg'><b id='TbYPg'><form id='TbYPg'><ins id='TbYPg'></ins><ul id='TbYPg'></ul><sub id='TbYPg'></sub></form><legend id='TbYPg'></legend><bdo id='TbYPg'><pre id='TbYPg'><center id='TbYPg'></center></pre></bdo></b><th id='TbYPg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TbYPg'><tfoot id='TbYPg'></tfoot><dl id='TbYPg'><fieldset id='TbYPg'></fieldset></dl></div>

                            主站蜘蛛池模板: 中文字幕av一区二区三区 | 国产日韩精品一区二区 | 久久久一区二区 | 91啪亚洲精品 | 亚洲一区二区视频在线观看 | 精品综合视频 | 天堂一区二区三区 | 中文字幕欧美在线观看 | 夜夜骑av| 一级毛片免费视频观看 | 欧美亚洲视频在线观看 | 91免费观看国产 | 在线免费观看黄网 | 亚洲精品欧美 | 一区二区三区四区在线 | 日韩一区和二区 | 中文字幕一区在线观看视频 | 天天操天天玩 | 亚洲成人av在线播放 | 亚洲精品一区二区三区蜜桃久 | 亚洲视频免费在线播放 | 亚洲区视频 | 精品三级在线观看 | 天天干天天玩天天操 | 成人av在线播放 | 久久国产日韩 | 成人激情视频免费在线观看 | 国产丝袜一区二区三区免费视频 | 91亚洲国产成人久久精品网站 | 精品视频一区二区三区 | 好婷婷网| 国产探花在线观看视频 | 97人人澡人人爽91综合色 | 五月精品视频 | 精品成人免费视频 | 三区在线| 亚洲激精日韩激精欧美精品 | 一区二区国产精品 | 四虎首页| 午夜免费精品视频 | 欧美性jizz18性欧美 |