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

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

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

      <tfoot id='IFf3k'></tfoot>
        <bdo id='IFf3k'></bdo><ul id='IFf3k'></ul>
      <legend id='IFf3k'><style id='IFf3k'><dir id='IFf3k'><q id='IFf3k'></q></dir></style></legend>
    2. Python/Kivy:從一個類調用函數到另一個類并在 Pyt

      Python/Kivy : Call function from one class to another class and show widget in Python(Python/Kivy:從一個類調用函數到另一個類并在 Python 中顯示小部件)
      <legend id='8ZApt'><style id='8ZApt'><dir id='8ZApt'><q id='8ZApt'></q></dir></style></legend>
          <i id='8ZApt'><tr id='8ZApt'><dt id='8ZApt'><q id='8ZApt'><span id='8ZApt'><b id='8ZApt'><form id='8ZApt'><ins id='8ZApt'></ins><ul id='8ZApt'></ul><sub id='8ZApt'></sub></form><legend id='8ZApt'></legend><bdo id='8ZApt'><pre id='8ZApt'><center id='8ZApt'></center></pre></bdo></b><th id='8ZApt'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8ZApt'><tfoot id='8ZApt'></tfoot><dl id='8ZApt'><fieldset id='8ZApt'></fieldset></dl></div>

        • <small id='8ZApt'></small><noframes id='8ZApt'>

            <tbody id='8ZApt'></tbody>

              <tfoot id='8ZApt'></tfoot>
              • <bdo id='8ZApt'></bdo><ul id='8ZApt'></ul>

                本文介紹了Python/Kivy:從一個類調用函數到另一個類并在 Python 中顯示小部件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在使用 Python-2.7 和 Kivy.當我運行 test.py 時,會顯示一個顯示按鈕.當我單擊顯示按鈕時,會顯示一個標簽和值.我正在從數據庫中獲取它,但現在我將它定義為一個靜態數組.

                I am using Python-2.7 and Kivy. When I run test.py then a show button shows. When I click on the show button then a label and value shows. I am fetching it from the database but now I defined it as a static array.

                當我點擊 Item1 標簽然后調用 def open_form 并在使用 id 調用 EditPopup(self) 后傳遞 id 11 并顯示一個帶有值的彈出窗口.

                When I click on Item1 label then call def open_form and pass id 11 after calling EditPopup(self) with id and show a popup with value.

                之后我更改 itemCode 并單擊確定按鈕,然后它會更新數據庫中的數據.

                After that I change itemCode and click on the ok button then it updates data in the database.

                之后我調用 Invoice().abc() 然后它在 Pycharm 控制臺中打印更新的數據,但不顯示 layout.add_widget 中的最新數據(彈出窗口).

                After that I call Invoice().abc() then it prints the updated data in Pycharm console but not showing latest the data in layout.add_widget(Popup window).

                誰能告訴我哪里出錯了?

                Can someone tell me where am I making a mistake?

                from kivy.uix.label import Label
                from kivy.uix.screenmanager import Screen
                from kivy.app import App
                from kivy.core.window import Window
                from functools import partial
                from kivy.uix.popup import Popup
                from kivy.properties import BooleanProperty, ListProperty, StringProperty, ObjectProperty, NumericProperty
                import sqlite3 as lite
                #con = lite.connect('test.db')
                
                #con.text_factory = str
                #cur = con.cursor()
                Window.clearcolor = (0.5, 0.5, 0.5, 1)
                Window.size = (600, 600)
                
                class MyLabel(Label):
                    pass
                
                
                class EditPopup(Popup):
                    mode = StringProperty("")
                    label_rec_id = StringProperty("Id")
                    col_data = ListProperty(["?", "?", "?"])
                    index = NumericProperty(0)
                
                    def __init__(self, obj, **kwargs):
                        super(EditPopup, self).__init__(**kwargs)
                
                        if obj.mode == "Update":
                            #cur.execute("SELECT * FROM `item` WHERE itemId=?", (edit_id,))
                            #row = cur.fetchone()
                            row = (11, 'Item1', '1001')
                            print(row[0])
                            self.col_data[0] = str(row[0])
                            self.col_data[1] = row[1]
                            self.col_data[2] = row[2]
                
                    def update(self,obj):
                        #cur.execute("UPDATE `item` SET itemName=?, itemCode=? WHERE itemId=?",
                                #('Item1', 9999, 11))
                        #con.commit()
                        Invoice().abc()
                
                class Invoice(Screen):
                    def __init__(self, **kwargs):
                        super(Invoice, self).__init__(**kwargs)
                
                    def abc(self):
                        #fetching from database
                        #cur.execute("SELECT * FROM `item` order by itemId asc")
                        #rows = cur.fetchall()
                        rows = [(11, 'Item1', '1001'), (12, 'Item2', '2001'), (13, 'Item3', '102')]
                        print(rows)
                        layout = self.ids['invoices']
                        for row in rows:
                            layout.add_widget(MyLabel(text=str('[ref=world]' + row[1]) + '[/ref]',
                                                      size_hint_x=.35,
                                                      halign='left',
                                                      markup=True,
                                                      on_ref_press=partial(self.open_form, row[0])))
                
                    def open_form(self, id, *args):
                        global edit_id
                        edit_id = id
                        self.mode = "Update"
                        popup = EditPopup(self)
                        popup.open()
                
                class Test(App):
                
                    def build(self):
                        return Invoice()
                
                if __name__ == '__main__':
                    Test().run()
                

                test.kv

                <Button@Button>:
                    font_size: 15
                    font_name: 'Verdana'
                    size_hint_y:None
                    height: 30
                
                <MyLabel>:
                    font_size: 15
                    font_name: 'Verdana'
                    size_hint_y:None
                    height: 30
                    text_size: self.size
                    valign: 'middle'
                    canvas.before:
                        Color:
                            rgb: .6, .6, .6
                        Rectangle:
                            pos: self.pos
                            size: self.size
                
                <EditPopup>:
                    title: self.mode + " Item"
                    size_hint: None, None
                    title_size: 20
                    title_font: "Verdana"
                    size: 400, 275
                    auto_dismiss: False
                
                    BoxLayout:
                        orientation: "vertical"
                        GridLayout:
                            cols: 2
                            #backgroun_color: 0, 0.517, 0.705, 1
                            spacing: 10, 10
                            padding: 20, 20
                            Label:
                                text: root.label_rec_id
                                text_size: self.size
                            Label:
                                id: itemId
                                text: root.col_data[0]
                                text_size: self.size
                            Label:
                                text: "Item Name"
                                text_size: self.size
                                valign: 'middle'
                            TextInput:
                                id: itemName
                                text: root.col_data[1]
                                text_size: self.size
                            Label:
                                text: "State Code"
                                text_size: self.size
                                valign: 'middle'
                            TextInput:
                                id: itemCode
                                text: root.col_data[2]
                                text_size: self.size
                
                        GridLayout:
                            cols: 2
                            padding: 10, 0, 10, 10
                            spacing: 10, 10
                            row_default_height: '20dp'
                            size_hint: .55, .3
                            pos_hint: {'x': .25, 'y':.65}
                
                            Button:
                                size_hint_x: .5
                                text: "Ok"
                                on_release:
                                    root.update(root)
                                    root.dismiss()
                
                            Button:
                                size_hint_x: .5
                                text: "Cancel"
                                on_release: root.dismiss()
                
                
                
                <Invoice>:
                    BoxLayout:
                        orientation: "vertical"
                        padding : 15, 15
                
                        BoxLayout:
                            orientation: "vertical"
                            padding : 5, 5
                            size_hint: .6, None
                            pos_hint: {'x': .18,}
                
                
                            BoxLayout:
                                orientation: "horizontal"
                                padding : 5, 5
                                spacing: 10, 10
                                size: 800, 40
                                size_hint: 1, None
                
                                Button:
                                    text: "Show"
                                    size_hint_x: .05
                                    spacing_x: 30
                                    on_press:root.abc()
                
                        BoxLayout:
                            orientation: "horizontal"
                            size_hint: 1, 1
                
                            BoxLayout:
                                orientation: "vertical"
                                size_hint: .5, 1
                                padding : 0, 15
                                spacing: 10, 10
                                size: 500, 30
                
                                GridLayout:
                                    id: invoices
                                    cols: 2
                                    #orientation: "horizontal"
                                    padding : 5, 0
                                    spacing: 10, 0
                                    #size: 500, 30
                                    size_hint: 1, 1
                                    pos: self.pos
                                    size: self.size
                

                推薦答案

                您正在創建一個新的 Invoice 實例,而不是使用現有的實例.

                You are creating a new Invoice instance instead of using the existing one.

                 Invoice().abc()
                

                試試吧:

                class EditPopup(Popup):
                    mode = StringProperty("")
                    label_rec_id = StringProperty("Id")
                    col_data = ListProperty(["?", "?", "?"])
                    index = NumericProperty(0)
                
                    def __init__(self, obj, **kwargs):
                        super(EditPopup, self).__init__(**kwargs)
                        self.obj = obj # will need it later...
                
                    def update(self,obj):
                        #cur.execute("UPDATE `item` SET itemName=?, itemCode=? WHERE itemId=?",
                                #('Item1', 9999, 11))
                        #con.commit()
                
                        self.obj.abc()  # was Invoice().abc()
                

                這篇關于Python/Kivy:從一個類調用函數到另一個類并在 Python 中顯示小部件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='Xjttv'></tbody>
                      • <legend id='Xjttv'><style id='Xjttv'><dir id='Xjttv'><q id='Xjttv'></q></dir></style></legend>
                        <tfoot id='Xjttv'></tfoot>
                      • <small id='Xjttv'></small><noframes id='Xjttv'>

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

                          <bdo id='Xjttv'></bdo><ul id='Xjttv'></ul>
                          主站蜘蛛池模板: 91色视频在线观看 | 欧美亚洲综合久久 | 欧美9999| 精品国产乱码久久久久久影片 | 在线中文字幕视频 | 欧美日韩亚洲一区 | 一级黄色夫妻生活 | 中文字幕三区 | 欧美一区二区免费视频 | 亚洲国产一 | 亚洲三级在线观看 | 成人欧美一区二区三区在线播放 | 日韩精品在线观看一区二区三区 | h视频免费观看 | 日本a∨视频 | 日韩欧美二区 | 亚洲精品播放 | 免费午夜视频在线观看 | 九九久久这里只有精品 | 亚洲欧美精品在线观看 | av永久免费| 日p视频免费看 | 波波电影院一区二区三区 | 亚洲综合在线一区 | 欧美成人免费在线视频 | 午夜精品一区二区三区在线视频 | 成人午夜激情 | 91精品一区二区三区久久久久 | 亚洲人人 | 99re在线视频观看 | 久久中文字幕在线 | 国产欧美一级二级三级在线视频 | 中文精品视频 | www.久久影视 | 久久久.com| 午夜久久久| 精品熟人一区二区三区四区 | 69亚洲精品 | 久久高清 | 国产成人小视频 | 久久99国产精一区二区三区 |