无法在Kivy中访问弹出窗口内容

时间:2019-03-20 09:11:35

标签: python kivy

我在访问弹出窗口内容时遇到问题。 这是.py中的弹出类:

class LicencePopup(Popup):

    def dismiss_popup(self, *args):
        self.dismiss()

    def submit_licence(self):
        # print self.content.ids.licence_field.text
        # print self.ids.licence_field.text
        # print self.content.ids[licence_field].text

.kv中的弹出窗口如下:

<LicencePopup>:
    size_hint: .3, .35
    title: 'Enter license key'
    separator_height: 0
    title_size: 35
    BoxLayout:
        orientation: "vertical"
        TextInput:
            id: license_field
            multiline: False
            text: "59353-58506-87377-00410"
            font_size: 24
        Label:
            id: license_label
        BoxLayout:
            Button:
                text: "Cancel"
                on_release: root.dismiss_popup()
            Button:
                text: "Submit"
                on_release: root.submit_licence()

我的问题是如何从TextInput(id:licence_field)获取文本。 我已经尝试了一些方法(注释打印),但是无法正常工作。 你能帮忙吗?

0 个答案:

没有答案