【发布时间】:2021-01-12 01:18:44
【问题描述】:
我正在用 kivy 编写一个字典应用程序。我想从 textinput 获取文本并创建一个滚动视图小部件并将结果添加到小部件。
class dictionary(App):
def build(self):
self.layout = BoxLayout(orientation="vertical")
self.first_row = BoxLayout(orientation="horizontal", size_hint_y=1)
self.examples = BoxLayout(orientation="vertical", size_hint_y=10)
self.input_ = TextInput(hint_text="Search on ludwig.guru",
multiline=False,
size_hint_x=2,
size_hint_y=1)
self.search_button = Button(text="Search",
on_press=self.search,
size_hint_x=1,
size_hint_y=1)
self.first_row.add_widget(self.input_)
self.first_row.add_widget(self.search_button)
self.layout.add_widget(self.first_row)
self.layout.add_widget(self.examples)
return self.layout
if name == "__main__":
dictionary.run()
【问题讨论】:
-
你在 kivy 的官方网站上查看过相关文档吗?他们有一些很好的例子,如果你仍然没有得到它或卡住了,那么就@我,我会尽力帮助kivy.org/doc/stable/api-kivy.uix.scrollview.html