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

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

    3. <small id='rohNP'></small><noframes id='rohNP'>

      <tfoot id='rohNP'></tfoot>

      切換 kivy 小部件

      Switching kivy widgets(切換 kivy 小部件)
    4. <legend id='m3AQk'><style id='m3AQk'><dir id='m3AQk'><q id='m3AQk'></q></dir></style></legend>
        <bdo id='m3AQk'></bdo><ul id='m3AQk'></ul>

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

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

                <tfoot id='m3AQk'></tfoot>
              • 本文介紹了切換 kivy 小部件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在使用 Kivy python 庫.

                I am using the Kivy python library.

                我定義了兩個小部件.

                程序運行時,我運行第一個小部件.

                When the program runs, I run the first widget.

                當那個小部件按鈕被按下時,我希望它消失并被第二個小部件替換.

                When that widgets button is pressed, I want it to dissapear and be replaced with the second widget.

                這是兩個小部件的 .kv

                Here is the .kv for the two widgets

                #uitest.kv
                <TestForm>:
                    canvas:
                        Rectangle:
                            pos: self.center_x, 0
                            size: 10, self.height
                
                    BoxLayout:
                        size: root.size
                        padding: 40
                        Button:
                            text: 'Hello'
                            on_release: root.testCallback()
                
                <TestForm2>:
                    canvas:
                        Rectangle:
                            pos: self.center_x, 0
                            size: self.height, 10
                

                我的主要 python 文件運行應用程序,并返回第一個小部件

                My main python file runs the app, and returns the first widget

                #main.py
                from testform import TestForm
                from kivy.app import App
                
                class UITestApp(App):
                    def build(self):
                        return TestForm()
                
                # Main launching point
                if __name__ in ('__main__', '__android__'):
                    UITestApp().run()
                

                我的第一個小部件有一個回調.這是有問題的代碼所屬的地方

                My first widget has a callback. This is where the code-in-question belongs

                from testform2 import TestForm2
                from kivy.uix.widget import Widget
                
                class TestForm(Widget):
                    def testCallback(self):
                        TestForm2() # Code in question goes here. @TODO replace this widget with TestForm2 widget.
                

                這里的想法是擁有一個用戶界面管理器.該管理器不像樹那樣運行 UI,而是像列表和堆棧一樣運行.該列表包含我所有的 UI 表單的實例.堆棧保存所述表單的遍歷,每當我們跳轉到一個表單時,我們將其推送到堆棧并渲染"或其他任何一個.

                The idea here is to have a user interface manager. This manager doesn't run the UI like a tree, but like a list and stack. The list holds instances of all my UI Forms. The stack holds the traversal of said forms, whenever we jump to a form we push it to the stack and "render" or whatever that one.

                我選擇了我的答案,但在搜索中我還找到了 Screen 對象:http://kivy.org/docs/api-kivy.uix.screenmanager.html就個人而言,clear() 和 add() 命令更強大,但如果您有興趣,屏幕會從您手中奪走很多東西.過渡效果也是如此.

                I chose my answer, but in my searches I also found the Screen object: http://kivy.org/docs/api-kivy.uix.screenmanager.html Personally, the clear() and add() commands are more powerful, but the screen takes a lot of that out of your hands if you're interested. Transition effects too.

                推薦答案

                我的建議是有一個界面管理器小部件,然后您可以為您的 UI 表單提供各種小部件.

                My suggestion is to have an interface manager widget, then you can have various widgets for your UI forms.

                import kivy
                from kivy.uix.label import Label
                from kivy.uix.button import Button
                from kivy.uix.boxlayout import BoxLayout
                from kivy.app import App
                
                class InterfaceManager(BoxLayout):
                
                    def __init__(self, **kwargs):
                        super(InterfaceManager, self).__init__(**kwargs)
                
                        self.first = Button(text="First")
                        self.first.bind(on_press=self.show_second)
                
                        self.second = Button(text="Second")
                        self.second.bind(on_press=self.show_final)
                
                        self.final = Label(text="Hello World")
                        self.add_widget(self.first)
                
                    def show_second(self, button):
                        self.clear_widgets()
                        self.add_widget(self.second)
                
                    def show_final(self, button):
                        self.clear_widgets()
                        self.add_widget(self.final)
                
                
                class MyApp(App):
                    def build(self):
                        return InterfaceManager(orientation='vertical')
                
                if __name__ == '__main__':
                    MyApp().run()
                

                當然,你不會那樣組織它.您可以將所有表單保存在 Container 對象的字典中,并有一個通用回調,通過鍵提供另一種表單.

                You wouldn't structure it like that of course. You could hold all your forms in a dictionary on the Container object and have a universal callback which provides another form by key.

                class InterfaceManager(BoxLayout):
                
                    def __init__(self, **kwargs):
                        super(InterfaceManager, self).__init__(**kwargs)
                        self.forms = {}
                
                    def add_form(self, key, form):
                        self.forms[key] = form
                
                    def uniCallback(self, button):
                        self.clear_widgets()
                        # You could introduce a more elegant key
                        # handling system here.
                        self.add_widget(self.forms[button.text])
                

                這篇關于切換 kivy 小部件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 - 自動更改角色顏色)

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

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

                • <legend id='mbvvH'><style id='mbvvH'><dir id='mbvvH'><q id='mbvvH'></q></dir></style></legend>
                    <tfoot id='mbvvH'></tfoot>

                          <tbody id='mbvvH'></tbody>

                        <i id='mbvvH'><tr id='mbvvH'><dt id='mbvvH'><q id='mbvvH'><span id='mbvvH'><b id='mbvvH'><form id='mbvvH'><ins id='mbvvH'></ins><ul id='mbvvH'></ul><sub id='mbvvH'></sub></form><legend id='mbvvH'></legend><bdo id='mbvvH'><pre id='mbvvH'><center id='mbvvH'></center></pre></bdo></b><th id='mbvvH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mbvvH'><tfoot id='mbvvH'></tfoot><dl id='mbvvH'><fieldset id='mbvvH'></fieldset></dl></div>
                          主站蜘蛛池模板: 久久精品国产一区二区 | 福利一区二区在线 | 午夜精品一区二区三区在线 | 狠狠干美女 | 日韩av大片免费看 | 超碰免费观看 | 久久精品国产一区二区电影 | 国产一区二区免费 | 久久久九九 | 91久久精品一区二区二区 | 欧美精品中文字幕久久二区 | 亚洲导航深夜福利涩涩屋 | 国产999精品久久久久久 | 精品视频在线播放 | 99精品国产在热久久 | 最新中文字幕在线 | 久久97精品 | 久久久精品网 | 国产日韩精品在线 | 亚洲成人免费在线 | 国产黑丝av | 成人免费影院 | 97久久精品午夜一区二区 | 久久综合一区二区三区 | 欧美日韩在线观看一区 | 成人久久久 | 色综网 | 日本免费一区二区三区四区 | 国产精品久久国产精品 | 亚洲成人中文字幕 | 国产精品18久久久 | 中文字幕av一区 | 国产特黄一级 | 亚洲精品大片 | 91精品国产91久久久久游泳池 | 国产精品不卡一区 | 久草电影网| 野狼在线社区2017入口 | 黄色av网站在线免费观看 | 国产香蕉视频 | 欧美成年人 |