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

  1. <legend id='V90lJ'><style id='V90lJ'><dir id='V90lJ'><q id='V90lJ'></q></dir></style></legend>
  2. <tfoot id='V90lJ'></tfoot>
      • <bdo id='V90lJ'></bdo><ul id='V90lJ'></ul>
    1. <small id='V90lJ'></small><noframes id='V90lJ'>

      Python kivy - 如何减少 TextInput 的高度

      时间:2023-10-09
      • <legend id='v8jI9'><style id='v8jI9'><dir id='v8jI9'><q id='v8jI9'></q></dir></style></legend>

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

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

                本文介绍了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 的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Kivy:标签文本在 for 循环期间不更新 下一篇:如何分析 Kivy 应用程序?

                相关文章

                最新文章

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

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

                  1. <small id='CxU64'></small><noframes id='CxU64'>