首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >kivy文本输入中的多个文本字段

kivy文本输入中的多个文本字段
EN

Stack Overflow用户
提问于 2020-06-07 20:49:26
回答 1查看 348关注 0票数 0

我正在使用kivy开发一个科学计算器,有没有一种方法可以在kivy文本输入中插入多个文本字段,如下图所示。谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2020-06-08 11:12:03

我不确定您到底想要什么,但是您可以组合TextInput小部件。下面是一个示例:

代码语言:javascript
复制
from kivy.app import App
from kivy.factory import Factory
from kivy.lang import Builder

kv = '''
<-TextInputNoBorder@TextInput>:
    # eliminates the TextInput border
    canvas.before:
        Color:
            rgba: self.background_color
        Rectangle:
            pos: self.pos
            size: self.size
        Color:
            rgba:
                (self.cursor_color
                if self.focus and not self._cursor_blink
                else (0, 0, 0, 0))
        Rectangle:
            pos: self._cursor_visual_pos
            size: root.cursor_width, -self._cursor_visual_height
        Color:
            rgba: self.disabled_foreground_color if self.disabled else (self.hint_text_color if not self.text else self.foreground_color)

<MyTextInput@BoxLayout>:
    # combine three TextInput Widgets to appear as one
    orientation: 'vertical'
    TextInputNoBorder:
        id: ti1
        text: 'This is One'
    TextInputNoBorder:
        id: ti2
        text: 'This is Two'
    TextInputNoBorder:
        id: ti3
        text: 'This is Three'
'''

class TestApp(App):
    def build(self):
        Builder.load_string(kv)
        return Factory.MyTextInput()

TestApp().run()

本例只垂直堆叠了三个TextInput小部件,但可以用多种方式排列和调整大小。TextInputNoBorder小部件通过重新定义TextInput小部件的外观来扩展它(消除了边框)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62245569

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档