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

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

    <tfoot id='VN1X7'></tfoot>
    1. <legend id='VN1X7'><style id='VN1X7'><dir id='VN1X7'><q id='VN1X7'></q></dir></style></legend>
        <bdo id='VN1X7'></bdo><ul id='VN1X7'></ul>

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

    2. 獲取kivy中選中復選框的值

      get value of selected checkbox in kivy(獲取kivy中選中復選框的值)
      <legend id='1t24W'><style id='1t24W'><dir id='1t24W'><q id='1t24W'></q></dir></style></legend>

      <small id='1t24W'></small><noframes id='1t24W'>

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

                <tbody id='1t24W'></tbody>

              • <bdo id='1t24W'></bdo><ul id='1t24W'></ul>
              • 本文介紹了獲取kivy中選中復選框的值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                import sqlite3 as lite
                
                from kivy.uix.screenmanager import Screen
                from kivy.app import App
                from kivy.lang import Builder
                from kivy.core.window import Window
                
                Window.size = (600, 325)
                
                class UserGroup(Screen):
                
                    def insert_data(self, arg1,arg2):
                        print(arg1)
                        print(arg2)
                
                
                class FactUserGroup(App):
                
                    def build(self):
                        self.root = Builder.load_file('test.kv')
                        return self.root
                
                
                if __name__ == '__main__':
                    FactUserGroup().run()
                

                test.kv

                <CustomLabel@Label>:
                    text_size: self.size
                    valign: "middle"
                    padding_x: 5
                
                <SingleLineTextInput@TextInput>:
                    multiline: False
                
                <GreenButton@Button>:
                    background_color: 1, 1, 1, 1
                    size_hint_y: None
                    height: self.parent.height * 0.120
                
                UserGroup
                
                    GridLayout:
                        cols: 2
                        padding : 30,30
                        spacing: 20, 20
                        row_default_height: '30dp'
                
                        Label:
                            text: 'Male'
                            text_size: self.size
                            valign: 'middle'
                
                        CheckBox:
                            group: 'check'
                            id : chk
                
                
                        Label:
                            text: 'Female'
                            text_size: self.size
                            valign: 'middle'
                
                        CheckBox:
                            group: 'check'
                
                        CustomLabel:
                            text: 'age'
                            text_size: self.size
                            valign: 'middle'
                
                        SingleLineTextInput:
                            id: age
                
                
                        GreenButton:
                            text: 'Ok'
                            on_press: root.insert_data(chk.text,age.text)
                
                
                        GreenButton:
                            text: 'Cancel'
                            on_press: app.stop()
                

                如何獲取復選框的值?我正在使用 age.text 獲取年齡文本框的值,但我不知道復選框的值?
                單擊確定"時,如何獲取選中的復選框值并傳入 root.insert_data.

                How to get value of checkbox?I am getting value of age textbox using age.text but checkbox value i don't know?
                When click on 'Ok' then How to get selected checkbox value and pass in root.insert_data.

                推薦答案

                您可以通過其 active 屬性來獲取復選框的選中狀態,因此請嘗試更改:

                You can get the checked state of a checkbox with its active property, so try change:

                GreenButton:
                    text: 'Ok'
                    on_press: root.insert_data(chk.active ,age.text)
                

                在此代碼段中,chk.text 已更改為 chk.active,這對我很有效.

                In this snippet chk.text was changed to chk.active which works for me properly.

                在 https://kivy.org/docs 查看更多關于 kivy 復選框的參考資料/api-kivy.uix.checkbox.html

                希望對您有所幫助.試試看吧.

                Hope it helps. Give it a try.

                因此,為了能夠獲取每個復選框的屬性和文本輸入,您可以將 ObjectProperties 分配給小部件,并且可以將它們鏈接到您的 test.py文件.

                So in order to be able to get the properties of each checkbox and the text input you can assign ObjectProperties to the widgets, and you can link them to your test.py file.

                修改后的來源:

                from kivy.uix.screenmanager import Screen
                from kivy.app import App
                from kivy.lang import Builder
                from kivy.core.window import Window
                from kivy.properties import ObjectProperty
                
                Window.size = (600, 325)
                
                class UserGroup(Screen):
                    male = ObjectProperty(None)
                    female = ObjectProperty(None)
                    age = ObjectProperty(None)
                    
                    def insert_data(self):
                        if self.male.active:
                            print('Male')
                        elif self.female.active:
                            print('Female')
                        else:
                            print('No gender selected')
                        print(self.age.text)
                
                
                class FactUserGroup(App):
                
                    def build(self):
                        self.root = Builder.load_file('test.kv')
                        return self.root
                
                
                if __name__ == '__main__':
                    FactUserGroup().run()
                

                .py 文件中,您可以找到 ObjectProperty 的新導入.您還可以看到,在 UserGroup 中定義了三個新屬性來與視圖交互,并且在 UserGroup.insert_data 中的修改非常簡單.

                In the .py file you can find a new import of ObjectProperty. Also you can see that three new properties were defined in UserGroup to interact with the view, and the modifications in UserGroup.insert_data are straightforward.

                <CustomLabel@Label>:
                    text_size: self.size
                    valign: "middle"
                    padding_x: 5
                
                <SingleLineTextInput@TextInput>:
                    multiline: False
                
                <GreenButton@Button>:
                    background_color: 1, 1, 1, 1
                    size_hint_y: None
                    height: self.parent.height * 0.120
                
                UserGroup
                
                    male: chk_male
                    female: chk_female
                    age: txt_age
                
                    GridLayout:
                        cols: 2
                        padding : 30,30
                        spacing: 20, 20
                        row_default_height: '30dp'
                
                        Label:
                            text: 'Male'
                            text_size: self.size
                            valign: 'middle'
                
                        CheckBox:
                            group: 'check'
                            id : chk_male
                
                        Label:
                            text: 'Female'
                            text_size: self.size
                            valign: 'middle'
                
                        CheckBox:
                            group: 'check'
                            id: chk_female
                
                        CustomLabel:
                            text: 'age'
                            text_size: self.size
                            valign: 'middle'
                
                        SingleLineTextInput:
                            id: txt_age
                
                
                        GreenButton:
                            text: 'Ok'
                            on_press: root.insert_data()
                
                
                        GreenButton:
                            text: 'Cancel'
                            on_press: app.stop()
                

                .kv 文件中,兩個復選框的 id 和文本輸入被重命名為 chk_malechk_femaletxt_age 分別.

                In the .kv file the ids of the two checkboxes and the text input are renamed to chk_male, chk_female and txt_age respectively.

                您還可以看到,對象屬性鏈接是在 UserGroup 部分的開頭定義的.

                Also you can see that the object property links are defined at the beginning of the UserGroup section.

                希望它有意義并符合您的要求.

                Hope it makes sense and match your requirements.

                這篇關于獲取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 - 自動更改角色顏色)

                        <tbody id='26Mcc'></tbody>

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

                        • <small id='26Mcc'></small><noframes id='26Mcc'>

                          <tfoot id='26Mcc'></tfoot>

                          主站蜘蛛池模板: 亚洲免费在线观看 | 成人av播放| 完全免费在线视频 | 久久中文视频 | 国产精品大全 | 久久99精品久久久久久狂牛 | 欧美伊人久久久久久久久影院 | 91.xxx.高清在线 | 日韩免费一区二区 | 亚洲精品视频免费观看 | 国产精品一区久久久久 | 午夜精品一区 | 久久精品国产亚洲a | 久久久性 | 日日夜夜av | 亚洲精品美女视频 | 99久久精品国产一区二区三区 | 国产亚洲精品久久午夜玫瑰园 | 久久国产精品一区二区三区 | 精品久久久久久久久久久久 | 操视频网站| 日日骑 | 欧美一区二区在线免费观看 | 免费黄色录像视频 | 黄色一级免费 | 欧美13videosex性极品 | 最新国产精品 | 一区二区三区在线电影 | 精品久久99 | 亚洲欧美日韩一区二区 | 91av在线电影 | 三级av在线 | h视频在线免费看 | 日韩欧美一区二区三区四区 | 亚洲一区二区在线视频 | 日韩在线观看一区 | 国产精品久久久久久久久久软件 | 亚洲一区二区中文字幕在线观看 | 免费一级黄色 | 免费性视频 | 国产精品一区网站 |