我试图在泡泡中显示数字键盘,以便在Kivy中输入文本。有可能吗? 到目前为止,我已经:
Builder.load_string('''
<Numerickeyboard>
size_hint: (None, None)
size: (160, 120)
pos_hint: {'center_x': .5, 'y': .6}
BubbleButton:
text: 'Cut'
BubbleButton:
text: 'Copy'
BubbleButton:
text: 'Paste'
''')
class NumericKeyboard(Bubble):
pass
class CustomTextInput(TextInput):
def __init__(self, **kwargs):
super(CustomTextInput, self).__init__(**kwargs)
def on_focus(self, instance, value):
self.bubb = NumericKeyboard()
self.add_widget(self.bubb)
但泡沫不会出现。在
不能将小部件添加到文本输入,因为它不是布局。您应该将文本输入添加到布局中,然后将气泡添加到此布局中。试试这个:
是的,可以使用Kivy Bubble for TextInput小部件显示数字键盘。详情请参考下面的例子。在
注意:文本输入不会被过滤。在
示例
在主.py在
在试验电压在
^{pr2}$输出
相关问题 更多 >
编程相关推荐