【发布时间】:2020-06-07 12:49:25
【问题描述】:
【问题讨论】:
标签: python kivy kivy-language
【问题讨论】:
标签: python kivy kivy-language
不确定您到底想要什么,但您可以组合 TextInput 小部件。这是一个例子:
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 小部件。
【讨论】:
TextInput 中定义的,我的代码不会影响该定义。您的代码中肯定发生了其他事情。
TextInput 中的字段无关。这就是字体。