如何从kivy文件获取Id值到python。我的代码是

时间:2015-10-10 13:10:30

标签: python-3.x kivy

import kivy

from kivy.app import App

from kivy.lang import Builder

from kivy.config import Config

from kivy.core.window import Window

from kivy.properties import DictProperty
from datetime import date
import os

Window.size = (400,130)

from kivy.uix.boxlayout import BoxLayout

class MediBox(BoxLayout):

    from kivy.properties import ObjectProperty
    data = DictProperty({})

    theTxt = ObjectProperty(None)
    def getHere(self,*args):

        print('I want value here')

        print(len(args))

class MyApp(App):
    dateToday=str(date.today())
    def build(self):
        self.root = Builder.load_file('mediboxForm.kv')
        print("hiiiii")
        return self.root
if __name__ == '__main__':
    MyApp().run()

kv文件是

<MediBox@BoxLayout>:
    orientation: 'horizontal'
    mediBoxIn: 'default'
    theTxt: iAmTxt
    Label:
        text: root.mediBoxIn
    TextInput:
        id: iAmTxt


<MyApp@BoxLayout>:
    orientation: 'vertical'


    MediBox:
        id: firstName
        mediBoxIn: 'First Name'

    MediBox:
        id: middleName
        mediBoxIn: 'Middle Name'

    MediBox:
        id: lastName
        mediBoxIn: 'Last Name'


    MediBox:
        id: date
        mediBoxIn: 'Date'
        Label:
            text: app.dateToday

    MediBox:
        id: address
        mediBoxIn: 'Address Name'

    MediBox:
        id: phone
        mediBoxIn: 'Phone Number'

    MediBox:
        id: gender
        mediBoxIn: 'Gender'

    MediBox:
        id: age
        mediBoxIn: 'Age'

    Button:
        text: 'Submit  Patient Details'
        on_press: root.getHere()

MyApp

0 个答案:

没有答案