[英]Kivy: How to add padding to a Text Input
這只是一個簡單的問題-我想在文本輸入框中添加一些“填充”,以使其與上方的標簽對齊:請參見此處
這是我的.kv文件的相關部分:
<InstructionsLabel>:
font_size: 24
size_hint_y: None
color: 0.447, 0.094, 0.737, 1
text_size: root.width, None
size: self.texture_size
padding_x: 20
<LengthExactScreen>:
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
FloatLayout:
DirectionButton:
text: "Back"
pos_hint: {'left': 1, 'top': 1}
on_press:
root.manager.transition.duration = 0
root.manager.current = "tool_screen"
DirectionButton:
text: "Done"
pos_hint: {'right': 1, 'top': 1}
on_press: root.compute_orders(root.itemList, int(len_exact_input.text))
GridLayout:
cols: 1
pos_hint: {'top': 0.86}
BoxLayout:
size_hint_y: None
height: self.minimum_height
orientation: "vertical"
InstructionsLabel:
text: "Enter the number of items you want to order"
TextInput:
id: len_exact_input
size_hint: None, None
width: 300
height: 35
multiline: False
hint_text: ""
TextInput也具有padding屬性。
更改它以匹配標簽上的填充
TextInput:
padding_x:[20,0]
這是我編寫的示例應用程序,旨在查看您的代碼中采用了該應用程序。 不幸的是,您的代碼有幾個問題,這樣比較容易
from kivy.app import App
from kivy.base import Builder
from kivy.uix.boxlayout import BoxLayout
Builder.load_string("""
<rootwi>:
orientation: 'vertical'
Label:
font_size: 24
text: 'iuqwdouqwdoqdwpqwpow'
color: 0.447, 0.094, 0.737, 1
text_size: root.width, None
size: self.texture_size
padding_x: 20
TextInput:
padding_x:[20,0]
""")
class rootwi(BoxLayout):
pass
class MyApp(App):
def build(self):
return rootwi()
if __name__ == '__main__':
MyApp().run()
您還可以對@kivy文本輸入進行一些研究。 那應該給您所有您需要的信息以及更多。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.