【发布时间】:2019-02-04 09:19:11
【问题描述】:
我必须使用 kivy 在 python 中编写一个程序,该程序在文本框中获取文本并将其传递给执行网络抓取和很多事情的函数,然后返回字符串数组,数组中的最后一个元素是对数组所以我真的很困惑,花了很多时间。所以我必须写两个 kv 文件还是只写一个文件?这是我的简单 kivy 代码作为开始。
试过了还是不行
#textInput.py
from app import *
Builder.load_file('textInput.kv')
require('1.10.0')
class MainScreen(BoxLayout):
def __init__(self):
self.super(MainScreen, self).__init__()
def btn_click(self):
name =self.BoxLayout.BoxLayout.TextInput
#the function that takes the output of the text field
get_company_name(name)
#
#
#
# here I will call the function that returns the array so how to pass the answer
# and also pass to where ? shall I use the same kv file or create another one
class Test(App):
def build(self):
self.title = 'CompanyInfoApp'
return MainScreen()
if __name__ == '__main__':
Test().run()
lbl:我的标签 方向:'垂直'
# Third section title
Label:
size_hint: (1, .1)
text: 'Welcome To compnay info App'
font_size: 25
# Third section Box
BoxLayout:
Button:
text:"let's start"
on_press:root.btn_click()
size_hint: (1, .2)
padding: [180, 180, 180, 180]
BoxLayout:
Label:
pos_hint:{'x': .3, 'y': .6}
text: 'Enter the Company Name:'
text_size: self.width-20, self.height-20
TextInput:
height: self.minimum_height
pos_hint:{'x': .3, 'y': .6}
multiline: False
text: ''
【问题讨论】: