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

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

    1. <legend id='NlkEC'><style id='NlkEC'><dir id='NlkEC'><q id='NlkEC'></q></dir></style></legend>
        <bdo id='NlkEC'></bdo><ul id='NlkEC'></ul>
      1. <tfoot id='NlkEC'></tfoot>

        如何在 kivy python 中使用滚动条

        how to use scrollbar in kivy python(如何在 kivy python 中使用滚动条)

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

          1. <tfoot id='BFO9U'></tfoot>

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

                  <legend id='BFO9U'><style id='BFO9U'><dir id='BFO9U'><q id='BFO9U'></q></dir></style></legend>
                    <tbody id='BFO9U'></tbody>
                  本文介绍了如何在 kivy python 中使用滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  谁能告诉我如何在这段代码中使用滚动条?其次,是否有任何方法可以对齐标签和 TextInput,以便 TextInput 中的文本无论有多少 Input 都将清晰可见.这里对齐意味着:如果有 100s(数百或数千)个 TextInputs ,则 TextInput 内的文本应该是正确可见的.实际上,当我在代码中给出一些(间距 = 50)时,在大约 20 秒的输入后,文本无法正常显示.提前致谢.

                  从 kivy.app 导入 App从 kivy.uix.tabbedpanel 导入 TabbedPanel从 kivy.uix.boxlayout 导入 BoxLayout从 kivy.properties 导入 StringProperty从 kivy.uix.textinput 导入 TextInput从 kivy.uix.checkbox 导入 CheckBox从 kivy.lang 导入生成器ROWS = ['Goc','COC','EEE','abs','kju','iop','nmg','gty','jkio','dbkgcd','udbcbjkb']builder.load_string("""<测试>:do_default_tab: 假选项卡面板项:文本:'page1'桌子:填充:50、50、50、50方向:垂直"<行>:间距:50size_hint_x: 1txt: txtinpt.text标签:文本:root.txt文本输入:编号:txtinpt文本:root.txt禁用:不是 CheckBox.active复选框:id:复选框文本:'复选框'活跃:假按钮:文字:'保存'""")类表(BoxLayout):def __init__(self, **kwargs):超级(表,自我).__init__(**kwargs)对于 ROWS 中的行:self.add_widget(行(行))类行(BoxLayout):txt = 字符串属性()def __init__(self, row, **kwargs):超级(行,自我).__init__(**kwargs)self.txt = 行类测试(TabbedPanel):经过我的应用程序(应用程序)类:定义构建(自我):测试 = 测试()返回测试如果 __name__ == '__main__':MyApp().run()

                  解决方案

                  接下来的步骤是:

                  1. TabbedPanelItem 中添加一个 ScrollView 并将 Table 放入其中.
                  2. 使用 size_hint_y = None 防止 boxlayout (Table) 自动调整其高度以适应其父窗口小部件的高度.
                  3. 指定高度.

                  代码可能是:

                  从 kivy.app 导入 App从 kivy.uix.tabbedpanel 导入 TabbedPanel从 kivy.uix.boxlayout 导入 BoxLayout从 kivy.properties 导入 StringProperty从 kivy.uix.textinput 导入 TextInput从 kivy.uix.checkbox 导入 CheckBox从 kivy.lang 导入生成器ROWS = ['Goc','COC','EEE','abs','kju','iop','nmg','gty','jkio','dbkgcd','udbcbjkb']builder.load_string("""<测试>:do_default_tab: 假选项卡面板项:文本:'page1'滚动视图:桌子:方向:垂直"size_hint_y:无高度:self.minimum_height填充:50、50、50、50<行>:间距:50size_hint_y:无size_hint_x: 1身高:100txt: txtinpt.text标签:文本:root.txt文本输入:编号:txtinpt文本:root.txt禁用:不是 CheckBox.active复选框:id:复选框文本:'复选框'活跃:假按钮:文字:'保存'""")类表(BoxLayout):def __init__(self, **kwargs):超级(表,自我).__init__(**kwargs)对于 ROWS 中的行:self.add_widget(行(行))类行(BoxLayout):txt = 字符串属性()def __init__(self, row, **kwargs):超级(行,自我).__init__(**kwargs)self.txt = 行类测试(TabbedPanel):经过我的应用程序(应用程序)类:定义构建(自我):测试 = 测试()返回测试如果 __name__ == '__main__':MyApp().run()

                  <块引用>

                  注意:修改只影响kv文件.

                  输出:

                  Can anybody tell me how to use scrollbar in this code? And secondly, is there any way to align the labels and TextInput so that text inside the TextInput will be visible clearly no matter how much Input will be there. Here alignment means: if there is 100s(hundreds or thousands) of TextInputs , the text inside TextInput should be properly visible. Actually when I was giving some (spacing = 50) in the code, after some 20s input, the text was not visible properly. Thanks in advance.

                  from kivy.app import App
                  from kivy.uix.tabbedpanel import TabbedPanel
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.properties import StringProperty
                  from kivy.uix.textinput import TextInput
                  from kivy.uix.checkbox import CheckBox
                  from kivy.lang import Builder
                  
                  ROWS = ['Goc', 'COC', 'EEE', 'abs' , 'kju' , 'iop' , 'nmg', 'gty', 'jkio', 'dbkgcd' , 'udbcbjkb']
                  
                  Builder.load_string("""
                  
                  <Test>:
                      do_default_tab: False
                  
                      TabbedPanelItem:
                          text: 'page1'
                  
                          Table:
                              padding: 50, 50, 50, 50
                              orientation: 'vertical'
                  
                  <Row>:
                      spacing: 50
                      size_hint_x: 1
                      txt: txtinpt.text
                      Label:
                          text: root.txt
                      TextInput:
                          id: txtinpt
                          text: root.txt
                          disabled: not CheckBox.active
                      CheckBox:
                          id:CheckBox 
                          text: 'CheckBox'
                          active: False
                      Button:
                          text: 'save'
                  
                  """)
                  class Table(BoxLayout):
                      def __init__(self, **kwargs):
                          super(Table, self).__init__(**kwargs)
                          for row in ROWS:
                              self.add_widget(Row(row))
                  
                  
                  
                  class Row(BoxLayout):
                      txt = StringProperty()
                      def __init__(self, row, **kwargs):
                          super(Row, self).__init__(**kwargs)
                          self.txt = row
                  
                  
                  
                  class Test(TabbedPanel):
                      pass
                  
                  class MyApp(App):
                  
                      def build(self):
                          test = Test()
                          return test
                  
                  
                  if __name__ == '__main__':
                      MyApp().run()
                  

                  解决方案

                  The steps to follow are:

                  1. Add a ScrollView to TabbedPanelItem and put Table inside it.
                  2. Prevent the boxlayout (Table) from automatically adapting its height to the height of its parent widget using size_hint_y = None.
                  3. Specify Row height.

                  The code could be:

                  from kivy.app import App
                  from kivy.uix.tabbedpanel import TabbedPanel
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.properties import StringProperty
                  from kivy.uix.textinput import TextInput
                  from kivy.uix.checkbox import CheckBox
                  from kivy.lang import Builder
                  
                  ROWS = ['Goc', 'COC', 'EEE', 'abs' , 'kju' , 'iop' , 'nmg', 'gty', 'jkio', 'dbkgcd' , 'udbcbjkb']
                  
                  Builder.load_string("""
                  
                  <Test>:
                      do_default_tab: False
                  
                      TabbedPanelItem:
                          text: 'page1'
                  
                          ScrollView:
                              Table:
                                  orientation: "vertical"
                                  size_hint_y: None
                                  height: self.minimum_height
                                  padding: 50, 50, 50, 50
                  
                  
                  <Row>:
                      spacing: 50
                      size_hint_y: None
                      size_hint_x: 1
                      height: 100
                      txt: txtinpt.text
                      Label:
                          text: root.txt
                  
                      TextInput:
                          id: txtinpt
                          text: root.txt
                          disabled: not CheckBox.active
                      CheckBox:
                          id:CheckBox 
                          text: 'CheckBox'
                          active: False
                      Button:
                          text: 'save'
                  
                  """)
                  class Table(BoxLayout):
                      def __init__(self, **kwargs):
                          super(Table, self).__init__(**kwargs)
                          for row in ROWS:
                              self.add_widget(Row(row))
                  
                  
                  
                  class Row(BoxLayout):
                      txt = StringProperty()
                      def __init__(self, row, **kwargs):
                          super(Row, self).__init__(**kwargs)
                          self.txt = row
                  
                  
                  class Test(TabbedPanel):
                      pass
                  
                  class MyApp(App):
                  
                      def build(self):
                          test = Test()
                          return test
                  
                  
                  if __name__ == '__main__':
                      MyApp().run()
                  

                  Note: The modifications only affect kv file.

                  Output:

                  这篇关于如何在 kivy python 中使用滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='HsGI1'><tr id='HsGI1'><dt id='HsGI1'><q id='HsGI1'><span id='HsGI1'><b id='HsGI1'><form id='HsGI1'><ins id='HsGI1'></ins><ul id='HsGI1'></ul><sub id='HsGI1'></sub></form><legend id='HsGI1'></legend><bdo id='HsGI1'><pre id='HsGI1'><center id='HsGI1'></center></pre></bdo></b><th id='HsGI1'></th></span></q></dt></tr></i><div id='HsGI1'><tfoot id='HsGI1'></tfoot><dl id='HsGI1'><fieldset id='HsGI1'></fieldset></dl></div>
                      <tfoot id='HsGI1'></tfoot>
                    1. <small id='HsGI1'></small><noframes id='HsGI1'>

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

                            <tbody id='HsGI1'></tbody>

                            <bdo id='HsGI1'></bdo><ul id='HsGI1'></ul>