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

    <tfoot id='OKog5'></tfoot>
    <legend id='OKog5'><style id='OKog5'><dir id='OKog5'><q id='OKog5'></q></dir></style></legend>

      <bdo id='OKog5'></bdo><ul id='OKog5'></ul>
    1. <small id='OKog5'></small><noframes id='OKog5'>

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

        .py 和 .kv 交互中的 Kivy 類

        Kivy class in .py and .kv interaction(.py 和 .kv 交互中的 Kivy 類)

      1. <legend id='hkLFP'><style id='hkLFP'><dir id='hkLFP'><q id='hkLFP'></q></dir></style></legend>
            <tbody id='hkLFP'></tbody>
          <tfoot id='hkLFP'></tfoot>
            <bdo id='hkLFP'></bdo><ul id='hkLFP'></ul>
          • <small id='hkLFP'></small><noframes id='hkLFP'>

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

                1. 本文介紹了.py 和 .kv 交互中的 Kivy 類的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我沒(méi)有完全理解 python 文件中的類和 kivy 語(yǔ)言是如何交互的.我目前正在修改 Kivy 的 Showcase 示例以增加我的理解.

                  I'm not fully grasping how classes in a python file and the kivy language interact. I'm currently modifying the Showcase example of Kivy to increase my understanding.

                  • main.py
                  • showcase.kv
                  • data/screens/test.kv
                  class Testy(BoxLayout):
                      ttext = 'Bla'
                      #other code
                  
                  class ShowcaseScreen(Screen):
                      fullscreen = BooleanProperty(False)
                  
                      def add_widget(self, *args):
                          if 'content' in self.ids:
                              return self.ids.content.add_widget(*args)
                          return super(ShowcaseScreen, self).add_widget(*args)
                  
                  
                  class ShowcaseApp(App):
                      #code
                  

                  test.kv

                  <Testy>:
                      orientation: 'vertical'
                  
                      Label:
                          text: root.ttext
                  
                  ShowcaseScreen:
                      name: 'LearnKanji'
                      fullscreen: True
                      #Some ref to <Testy>
                  

                  問(wèn)題

                  我想將我的代碼放在 Testy() 中,因?yàn)槲矣?jì)劃編寫(xiě)大量代碼來(lái)針對(duì)單個(gè)屏幕中發(fā)生的情況,我不想讓 ShowcaseScreen() 變得混亂,因?yàn)?ShowcaseScreen 也意味著用于其他屏幕.

                  Question

                  I want to have my code in Testy(), because I'm planning to write a lot of code aimed at what happens in that single screen and I don't want to clutter ShowcaseScreen(), because ShowcaseScreen is also meant for other screens.

                  為了澄清,在 test.kv 中我指的是變量 ttext.如果我沒(méi)有創(chuàng)建類 Testy() 我會(huì)這樣說(shuō):

                  To clarify, in test.kv I'm referring to the variable ttext. If I didn't make the class Testy() I would have put it as follows:

                  ShowcaseScreen:
                      name: 'LearnKanji'
                      fullscreen: True
                      BoxLayout:
                          text: root.ttext
                  

                  然后在 main.py 我需要放

                  And then in main.py I would need to put

                  class ShowcaseScreen(Screen):
                      ttext = 'Bla'
                  

                  但是,由于除了 Testy 之外的許多屏幕都使用 ShowcaseScreen() 類,因此將所有屏幕的所有代碼都放在這里會(huì)變得一團(tuán)糟.因此,我希望每個(gè)屏幕的代碼在一個(gè)單獨(dú)的類中.我認(rèn)為這對(duì)于更大的代碼項(xiàng)目來(lái)說(shuō)是一種更好的方式.

                  However since many screens besides Testy use the class ShowcaseScreen(), putting all the code for all screens in here would make it too much of a mess. Therefore I want the code per screen in a separate class. I think this is a better way for bigger code projects.

                  那么在test.kv文件中調(diào)用ShowcaseScreen:后怎么引用呢?這樣我就可以將用于 Testy 的代碼放在 Testy() 中,并使我的文件和類更有條理.

                  So how do I refer to after calling ShowcaseScreen: in the test.kv file? So that I can put the code meant for Testy in Testy() and keep my files and classes more organized.

                  推薦答案

                  您可以使用ScreenManager.看看這里,我更改了您的一些代碼以提供使用 ScreenManager 將每個(gè)屏幕的代碼分離到它們自己的類中的示例.如果這有問(wèn)題,請(qǐng)告訴我.

                  You can use the ScreenManager. Have a look here, I changed some of your code to provide an example of using the ScreenManager to seperate out the code for each screen into their own classes. If there are problems with this let me know.

                  ma??in.py:

                  from kivy.app import App
                  from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
                  from kivy.properties import ObjectProperty
                  
                  
                  class Testy(Screen):
                  
                      ttext = 'Screen 2'
                      #other code
                  
                  class ScreenTwo(Screen):
                      pass
                  
                  class Manager(ScreenManager):
                  
                      testy = ObjectProperty(None)
                      screen_2 = ObjectProperty(None)
                  
                  
                  class ShowcaseApp(App):
                  
                      def build(self):
                          return Manager(transition=FadeTransition())
                  
                  if __name__ == "__main__":
                      ShowcaseApp().run()
                  

                  kv 文件:

                  <Testy>:
                      BoxLayout:
                          Button:
                              text: root.ttext
                              on_press: root.manager.current = "screen_two"
                  
                  <ScreenTwo>:
                      BoxLayout:
                          Button:
                              text: "Screen 1"
                              on_press: root.manager.current = "testy_screen"
                  
                  
                  <Manager>:
                      id: screen_manager
                  
                      testy: testy
                      screen_2: screen_2
                  
                      Testy:
                          id: testy
                          name: 'testy_screen'
                          manager: screen_manager
                  
                      ScreenTwo:
                          id: screen_2
                          name: 'screen_two'
                          manager: screen_manager
                  

                  這篇關(guān)于.py 和 .kv 交互中的 Kivy 類的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

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

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

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

                          1. <tfoot id='GvhL2'></tfoot>

                            主站蜘蛛池模板: 亚洲成人网在线 | 国产精品久久 | 一级黄色毛片免费 | 国产高潮好爽受不了了夜夜做 | 国产1区在线 | 中文字幕第一页在线 | 亚洲在线 | 国产福利在线 | 国产二区精品视频 | 国产精品九九视频 | 91久久综合| 日韩中文一区二区三区 | www.五月天婷婷.com | a级毛片免费高清视频 | 国产日韩欧美另类 | 色嗨嗨 | 黄网站在线播放 | 久草成人网| 黄色大片免费观看 | 国产永久免费 | 久久久久中文字幕 | 亚洲二区视频 | 久久久亚洲一区 | 亚洲一区二区精品视频 | 日韩欧美精品在线 | 91精品国产一区二区三区 | 日本免费在线观看视频 | 久久国产精品首页 | 日本精品久久久久 | 亚洲色欧美另类 | 欧美久久视频 | 国内精品成人 | 夜夜精品浪潮av一区二区三区 | 欧美自拍第一页 | 中文字幕日韩欧美 | 自拍第1页 | 免费看黄色视屏 | 九九热在线免费观看 | 欧美一区二区三区在线观看 | 日韩a在线 | 久久精品成人 |