• <small id='ATPVJ'></small><noframes id='ATPVJ'>

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

        Python kivy - 如何减少 TextInput 的高度

        Python kivy - how to reduce height of TextInput(Python kivy - 如何减少 TextInput 的高度)

          <bdo id='Le86w'></bdo><ul id='Le86w'></ul>
        • <small id='Le86w'></small><noframes id='Le86w'>

                <tbody id='Le86w'></tbody>

              <tfoot id='Le86w'></tfoot>

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

                • <i id='Le86w'><tr id='Le86w'><dt id='Le86w'><q id='Le86w'><span id='Le86w'><b id='Le86w'><form id='Le86w'><ins id='Le86w'></ins><ul id='Le86w'></ul><sub id='Le86w'></sub></form><legend id='Le86w'></legend><bdo id='Le86w'><pre id='Le86w'><center id='Le86w'></center></pre></bdo></b><th id='Le86w'></th></span></q></dt></tr></i><div id='Le86w'><tfoot id='Le86w'></tfoot><dl id='Le86w'><fieldset id='Le86w'></fieldset></dl></div>
                • 本文介绍了Python kivy - 如何减少 TextInput 的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 kivy 为应用程序制作一个非常简单的 gui.没有什么复杂的,非常简单的布局.

                  I am using kivy to make a very simple gui for an application. Nothing complex, very simple layout.

                  尽管如此,我在使用 TextInputs 时遇到了困难……它们总是以全高显示,我无法让它们调整为合理"的文本高度,例如高度.

                  Nevertheless I am having a hard time with TextInputs...They always display with full height and I can't manage to make them adjust to a "reasonable" text-height like height.

                  我使用 kv 文件样式,因为我发现它更简洁,更容易将其集成到现有应用程序中...我想尽可能减少应用程序的 gui-python 代码.

                  I am using the kv files style since I find it cleaner and easier to integrate it in an already existing app...I would like to reduce as much as possible the gui-python code of the app.

                  这是我为 TextInput 得到的(无用添加 gui 的其他部分).

                  Here is what I got for the TextInput (useless to add other parts of the gui).

                  Python 代码

                  # textInput.py
                  from kivy import require
                  from kivy.app import App
                  from kivy.uix.boxlayout import BoxLayout
                  from kivy.lang.builder import Builder
                  
                  Builder.load_file('path/to/kv/file/textInput.kv')
                  
                  require('1.10.0')
                  
                  class MainScreen(BoxLayout):
                      pass
                  
                  class Test(App):
                      def build(self):
                          self.title = 'Testing textInput'
                          return MainScreen()
                  
                  if __name__ == '__main__':
                      Test().run()
                  

                  KV 代码

                  # textInput.kv
                  <MainScreen>
                      orientation: 'vertical'
                  
                      # Third section title
                      Label:
                          size_hint: (1, .1)
                          text: 'Setup Connection'
                          font_size: 25
                  
                      # Third section Box
                      BoxLayout:
                          size_hint: (1, .2)
                          padding: [100, 0, 100, 0]
                          BoxLayout:
                              Label:
                                  size_hint: (.2, 1)
                                  text: 'Host'
                              TextInput:
                                  height: self.minimum_height
                                  multiline: False
                                  text: 'localhost'
                              Label:
                                  size_hint: (.2, 1)
                                  text: ''
                              Label:
                                  size_hint: (.2, 1)
                                  text: 'Port'
                              TextInput:
                                  size_hint: (.2, 1)
                                  multiline: False
                                  text: '502'
                  

                  我尝试了很多东西,在这里的代码中我尝试同时使用 size_hint 和 height...但没有一个有效..

                  I have tried lot of stuff, in the code here I am trying both to use size_hint and height...but none works..

                  推荐答案

                  要设置一个小部件的高度,首先将 size_hint_y 设置为 None 然后你可以设置height 到任何你想要的.

                  To set a height of a widget, first set the size_hint_y to None and then you can set the height to whatever you want.

                  TextInput:
                      size_hint: (.2, None)
                      height: 30
                      multiline: False
                      text: '502'
                  

                  这篇关于Python kivy - 如何减少 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中更改按钮或标签文本颜色)
                    <bdo id='9qNXW'></bdo><ul id='9qNXW'></ul>

                      <small id='9qNXW'></small><noframes id='9qNXW'>

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

                          <tfoot id='9qNXW'></tfoot>

                              <tbody id='9qNXW'></tbody>