<small id='rjxex'></small><noframes id='rjxex'>

<i id='rjxex'><tr id='rjxex'><dt id='rjxex'><q id='rjxex'><span id='rjxex'><b id='rjxex'><form id='rjxex'><ins id='rjxex'></ins><ul id='rjxex'></ul><sub id='rjxex'></sub></form><legend id='rjxex'></legend><bdo id='rjxex'><pre id='rjxex'><center id='rjxex'></center></pre></bdo></b><th id='rjxex'></th></span></q></dt></tr></i><div id='rjxex'><tfoot id='rjxex'></tfoot><dl id='rjxex'><fieldset id='rjxex'></fieldset></dl></div>
    • <bdo id='rjxex'></bdo><ul id='rjxex'></ul>

      <legend id='rjxex'><style id='rjxex'><dir id='rjxex'><q id='rjxex'></q></dir></style></legend>

      <tfoot id='rjxex'></tfoot>
      1. Kivy Python TextInput 显示气泡

        Kivy Python TextInput display Bubble(Kivy Python TextInput 显示气泡)
        <i id='PYADY'><tr id='PYADY'><dt id='PYADY'><q id='PYADY'><span id='PYADY'><b id='PYADY'><form id='PYADY'><ins id='PYADY'></ins><ul id='PYADY'></ul><sub id='PYADY'></sub></form><legend id='PYADY'></legend><bdo id='PYADY'><pre id='PYADY'><center id='PYADY'></center></pre></bdo></b><th id='PYADY'></th></span></q></dt></tr></i><div id='PYADY'><tfoot id='PYADY'></tfoot><dl id='PYADY'><fieldset id='PYADY'></fieldset></dl></div>
        1. <tfoot id='PYADY'></tfoot>
              <tbody id='PYADY'></tbody>

            <small id='PYADY'></small><noframes id='PYADY'>

          • <legend id='PYADY'><style id='PYADY'><dir id='PYADY'><q id='PYADY'></q></dir></style></legend>
              <bdo id='PYADY'></bdo><ul id='PYADY'></ul>

                  本文介绍了Kivy Python TextInput 显示气泡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I am trying to display numeric keyboard in bubble for TextInput in Kivy. Is it possible? So far I have:

                  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)
                  

                  But the bubble will not display.

                  解决方案

                  Yes, it is possible to display numeric key pad using Kivy Bubble for TextInput widget. Please refer to the example below for details.

                  Note: The text input is not filtered.

                  Example

                  main.py

                  from kivy.app import App
                  from kivy.uix.floatlayout import FloatLayout
                  from kivy.uix.bubble import Bubble, BubbleButton
                  from kivy.uix.label import Label
                  from kivy.properties import ObjectProperty
                  from kivy.lang import Builder
                  
                  
                  class CustomBubbleButton(BubbleButton):
                      pass
                  
                  
                  class NumericKeyboard(Bubble):
                      layout = ObjectProperty(None)
                  
                      def __init__(self, **kwargs):
                          super(NumericKeyboard, self).__init__(**kwargs)
                          self.create_bubble_button()
                  
                      def create_bubble_button(self):
                          numeric_keypad = ['7', '8', '9', '4', '5', '6', '1', '2', '3', '', '0', '.']
                          for x in numeric_keypad:
                              if len(x) == 0:
                                  self.layout.add_widget(Label(text=""))
                              else:
                                  bubb_btn = CustomBubbleButton(text=str(x))
                                  self.layout.add_widget(bubb_btn)
                  
                  
                  class BubbleShowcase(FloatLayout):
                      text_input = ObjectProperty(None)
                  
                      def show_bubble(self, *l):
                          if not hasattr(self, 'bubb'):
                              self.bubb = bubb = NumericKeyboard()
                              self.bubb.arrow_pos = "bottom_mid"
                              self.add_widget(bubb)
                  
                  
                  Builder.load_file("test.kv")
                  
                  
                  class TestBubbleApp(App):
                      title = "Numeric Key Pad - Using Bubble"
                  
                      def build(self):
                          return BubbleShowcase()
                  
                  
                  if __name__ == '__main__':
                      TestBubbleApp().run()
                  

                  test.kv

                  #:kivy 1.10.0
                  
                  <CustomBubbleButton>:
                      on_release:
                          app.root.text_input.text += self.text
                  
                  
                  <NumericKeyboard>:
                      layout: layout
                  
                      size_hint: (None, None)
                      size: (160, 120)
                      pos_hint: {'center_x': .5, 'y': .6}
                  
                      GridLayout:
                          id: layout
                          cols: 3
                  
                  <BubbleShowcase>:
                      text_input: text_input
                  
                      canvas:
                          Color:
                              rgba: 0, 1, 1, 1
                          Rectangle:
                              size: self.width, self.height
                      TextInput:
                          id: text_input
                          pos_hint: {'center_x': .5, 'y': .54}
                          size_hint: (0.2, 0.06)
                          cursor_blink: True
                          font_size: 20
                          multiline: False
                          on_focus:
                              root.show_bubble()
                  

                  Output

                  这篇关于Kivy Python TextInput 显示气泡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                  Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                  How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                  Centering an object in Kivy(在 Kivy 中将对象居中)
                  How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                  Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)
                  <i id='mbhEy'><tr id='mbhEy'><dt id='mbhEy'><q id='mbhEy'><span id='mbhEy'><b id='mbhEy'><form id='mbhEy'><ins id='mbhEy'></ins><ul id='mbhEy'></ul><sub id='mbhEy'></sub></form><legend id='mbhEy'></legend><bdo id='mbhEy'><pre id='mbhEy'><center id='mbhEy'></center></pre></bdo></b><th id='mbhEy'></th></span></q></dt></tr></i><div id='mbhEy'><tfoot id='mbhEy'></tfoot><dl id='mbhEy'><fieldset id='mbhEy'></fieldset></dl></div>

                    <bdo id='mbhEy'></bdo><ul id='mbhEy'></ul>
                        <tbody id='mbhEy'></tbody>

                      <small id='mbhEy'></small><noframes id='mbhEy'>

                    • <tfoot id='mbhEy'></tfoot>

                        1. <legend id='mbhEy'><style id='mbhEy'><dir id='mbhEy'><q id='mbhEy'></q></dir></style></legend>