python - 每当窗口大小发生变化时,如何让 textInput 调整以适应静态小部件
问题描述
我正在尝试将一个小部件锚定在其他两个不改变大小的小部件之间。
https://gyazo.com/caf7044f97ef5cceed7aeb6328d6baab 我试图防止小部件重叠,但我不知道如何去做。我希望中间小部件调整大小以适应它两侧的小部件,也可能在它下方。
#:kivy 2.0.0
<GeneratorScreen>:
FloatLayout:
pos:0,0
size: root.width, root.height
Label:
id: text_editor_output
background_color: (140, 146, 156, 1)
text: "placeholder"
size_hint:(.8, .8)
pos_hint: {'x': .04, 'y': .04}
pos_hint: {'bottom':1.0}
TextInput:
id: text_editor_input
markup: True
color: (255, 255, 255, 1)
text: 'type here'
size_hint:(.8, .8)
pos_hint: {'x': .04, 'y': .04}
pos_hint: {'bottom':1.0}
AnchorLayout:
anchor_x: "right"
anchor_y: "top"
size: root.width, root.height
GridLayout:
size_hint: None, None
pos_hint: {'x': .9, 'y': 1}
size:200, 200
cols: 3
pos_hint: {'right':1.0}
Button:
id: settlement_button
text: 'Settlement'
font_size: 10
size_hint: None, None
size: 67, 20
on_press: root.settlement()
Button:
id: npc_button
text: 'Npc'
font_size: 10
size_hint: None, None
size: 67, 20
on_press: root.npc()
Button:
id: store_button
text: 'Store'
font_size: 10
size_hint: None, None
size: 67, 20
Button:
id: other_button
text: 'other'
font_size: 10
size_hint: None, None
size: 67, 20
AnchorLayout:
anchor_x: "right"
anchor_y: "bottom"
size: root.width, root.height
TextInput:
id: gen_output
pos_hint: {'bottom': 1.0}
pos_hint: {'right':1.0}
size_hint: None, None
size: 200, 200
text: ''
font_size: 15
AnchorLayout:
anchor_x: "left"
anchor_y: "top"
size: root.width, root.height
Button:
size_hint: None, None
size: 30,30
text:"save"
on_press: root.save()
解决方案
推荐阅读
- swift - 为什么我的 TableView 单元格需要重用标识符?
- javascript - 如何使用 jQuery 制作图标幻灯片
- java - 格式化二维数字数组
- node.js - 无法发布/更新数据
- postgresql - PL/PostgreSQL 如何将变量转换为表名
- r - 如何将多变量向量值函数的输出收集到数据框中?
- amazon-web-services - 如何从 AWS CLI 上的旧访问密钥 ID 更新我的访问密钥 ID?
- python - 将 django python 中的二维码保存为 to_artistic 方法的 base64
- javascript - 'this' 在 Mongoose 中间件期间为空
- python - 是否可以实现多个目标?(OR-TOOLS 约束编程)