参考资料
8. 控件-Kivy中文编程指南-面试哥 (mianshigee.com)
# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
from kivy.core.window import Window
from kivy.metrics import Metrics
from kivy.lang import Builder
import csv
class pdApp(App):
def build(self):
return Builder.load_string('''
BoxLayout:
orientation:"vertical"
TextInput:
text:"isbn"
size_hint_max_y:"30dp"
Label:
id:"id_2"
text:"just scan"
Button:
text:"recommand bs"
size_hint_max_y:"30dp"
on_press: app.click_recommand_bs()
''')
def click_recommand_bs(self):
r=self.root.children
#r[2] 文本框isbn
#r[1]标签just scan
#r[0] 按钮recommand bs
TextInput_isbn = r[2]
Label_js = r[1]
Button_rb = r[0]
Label_js.text = TextInput_isbn.text
TextInput_isbn.text =""
#csv读取文件
f = open('A2.csv', 'r',encoding="utf-8")
with f:
reader = csv.reader(f)
for row in reader:
print(row)
#