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

      <tfoot id='y6QJ6'></tfoot>

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

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

        如何在 kivy python 中使用滚动条

        时间:2023-10-09
          <bdo id='0nyWi'></bdo><ul id='0nyWi'></ul>

          • <small id='0nyWi'></small><noframes id='0nyWi'>

            <tfoot id='0nyWi'></tfoot>

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

                <legend id='0nyWi'><style id='0nyWi'><dir id='0nyWi'><q id='0nyWi'></q></dir></style></legend>

                  <tbody id='0nyWi'></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 中使用滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Kivy python 中最大化滚动条? 下一篇:如何在kivy中更改弹出颜色

                  相关文章

                  最新文章

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

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

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