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

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

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

        <tfoot id='TZfLJ'></tfoot>

        • <bdo id='TZfLJ'></bdo><ul id='TZfLJ'></ul>
      2. <legend id='TZfLJ'><style id='TZfLJ'><dir id='TZfLJ'><q id='TZfLJ'></q></dir></style></legend>
      3. 從現有實例調用方法

        Calling a method from an existing instance(從現有實例調用方法)
          <bdo id='wBUhV'></bdo><ul id='wBUhV'></ul>
              <tbody id='wBUhV'></tbody>

            <small id='wBUhV'></small><noframes id='wBUhV'>

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

                • <legend id='wBUhV'><style id='wBUhV'><dir id='wBUhV'><q id='wBUhV'></q></dir></style></legend>

                  本文介紹了從現有實例調用方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我對面向對象編程的理解有點不穩定,所以如果你有任何鏈接可以幫助解釋這些概念,我會很高興看到它們!

                  My understanding of Object Orientated Programming is a little shaky so if you have any links that would help explain the concepts it would be great to see them!

                  我已經稍微縮短了代碼.基本原則是我有一個以主 Controller 類的實例開始的游戲.當游戲打開時,Popup 類被打開.事件發生如下:

                  I've shortened the code somewhat. The basic principle is that I have a game that starts with an instance of the main Controller class. When the game is opened the Popup class is opened. The events happens as follows:

                  1. 點擊彈窗上的開始按鈕
                  2. 方法 start_click() 運行
                  3. 調用Controller實例中的start_game()方法
                  4. 這又將原始控制器實例中的游戲狀態更改為真"

                  我的問題在于第 3 步.我收到的錯誤消息是:

                  My problem is with step 3. The error message I get is:

                  TypeError: unbound method start_game() must be called with Controller 
                  instance as first argument (got nothing instead)
                  

                  我想 StartPopUp 類中需要對 Controller 類進行一些引用.但我不太明白如何創建該參考?

                  I guess there needs to be some reference to the Controller class in the StartPopUp class. But I don't quite understand how to create that reference?

                  import kivy
                  kivy.require('1.8.0')
                  
                  from kivy.app import App
                  from kivy.uix.widget import Widget
                  from kivy.clock import Clock
                  from kivy.properties import BooleanProperty, NumericProperty, ObjectProperty
                  from kivy.uix.popup import Popup
                  from kivy.lang import Builder
                  
                  Builder.load_string('''
                  <StartPopUp>            
                      size_hint: .2, .2
                      auto_dismiss: False
                      title: 'Welcome'
                      Button:
                          text: 'Play'
                          on_press: root.start_click()
                          on_press: root.dismiss()
                  
                  ''')
                  
                  class StartPopUp(Popup):
                  
                      def __init__(self, **kw):
                          super(StartPopUp, self).__init__(**kw)
                  
                      def start_click(self):
                          Controller.start_game()                    
                  
                  class Controller(Widget):
                      playing_label = BooleanProperty(False)          #Intitial phase of game is off
                  
                      def __init__(self, **kw):
                          super(Controller, self).__init__(**kw)        
                  
                      def start_popup(self, dt):    
                          sp = StartPopUp()
                          sp.open()
                  
                      def start_game(self):
                          self.playing_label = True
                          print self.playing_label   
                  
                  class MoleHuntApp(App):
                  
                      def build(self):
                          game = Controller()
                          Clock.schedule_once(game.start_popup, 1)
                          return game
                  
                  if __name__ == '__main__':
                      MoleHuntApp().run() 
                  

                  提前致謝!

                  推薦答案

                  可以這樣傳遞實例

                  class StartPopUp(Popup):
                  
                      def __init__(self, controller, **kw):
                          super(StartPopUp, self).__init__(**kw)
                          self.controller = controller
                  
                      def start_click(self):
                          self.controller.start_game()
                  

                  在控制器中

                  def start_popup(self, dt):    
                      sp = StartPopUp(self)
                      sp.open()
                  

                  這篇關于從現有實例調用方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

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

                  • <tfoot id='Arr6p'></tfoot>

                    <small id='Arr6p'></small><noframes id='Arr6p'>

                        <tbody id='Arr6p'></tbody>
                        <legend id='Arr6p'><style id='Arr6p'><dir id='Arr6p'><q id='Arr6p'></q></dir></style></legend>

                          • <bdo id='Arr6p'></bdo><ul id='Arr6p'></ul>

                          • 主站蜘蛛池模板: 亚洲精品免费在线观看 | 欧美高清视频在线观看 | 欧美综合久久久 | 欧美在线视频观看 | 亚洲h在线观看 | 国产精品揄拍一区二区 | 国产激情在线观看 | 亚洲成av人影片在线观看 | 精品欧美一区二区久久久伦 | 日韩欧美精品在线 | 成人精品在线观看 | 亚洲日韩中文字幕一区 | 综合国产| 国产综合久久 | 亚洲免费福利视频 | 精品欧美久久 | 女生羞羞网站 | 一级黄色毛片免费 | 色综合久久天天综合网 | 精品一级| 日本不卡视频 | 亚洲国产精品一区二区第一页 | 成人免费一区二区三区牛牛 | 国产成人一区二区三区久久久 | 欧美在线a | 成人免费在线小视频 | 三级免费av | 亚洲一区二区三区四区五区午夜 | 国产亚洲欧美另类一区二区三区 | 手机看片169 | 二区av| 一区二区三区欧美 | 成人免费视屏 | 日韩在线成人 | 龙珠z在线观看 | 51ⅴ精品国产91久久久久久 | 精品伦精品一区二区三区视频 | 一区二区三区四区在线 | 91精品久久 | 国产精品免费在线 | 亚洲一区 |