- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图将 4 个水平盒子布局以垂直方式堆叠在 BoxLayout 中。
我的 KV 文件:
<HBoxWidget>:
BoxLayout:
size: root.size
pos: root.pos
id: boxlayout_h
orientation: 'horizontal'
Image:
source: '/Users/driftking9987/Desktop/fp.gif'
<VBoxWidget1>:
BoxLayout:
spacing: 10
orientation: "horizontal"
size: [1,.25]
pos: root.pos
Label:
text: "Status : "
color: [0,84,80,19]
Label:
text: "Pending"
color: [0,84,80,19]
Widget:
<ContainerBox>:
orientation: 'horizontal'
HBoxWidget:
VBoxWidget1:
我计划以垂直方式拥有多个 VBoxWidget
但它不起作用。
此外,为了实现[9] Label
,我想我会有一个具有2行的BoxLayout
,在水平方向上,第二行将具有上述属性。但这是行不通的。以下是我得到的。我尝试将 size_hint
设置为 1,.25
,即整个区域将分为 4 部分,但它没有给出所需的结果。
PY 文件:
from kivy.app import App
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
class HBoxWidget(Widget):
def __init__(self, **kwargs):
super(HBoxWidget, self).__init__(**kwargs)
class VBoxWidget1(Widget):
def __init__(self, **kwargs):
super(VBoxWidget1, self).__init__(**kwargs)
class ContainerBox(BoxLayout):
def __init__(self, **kwargs):
super(ContainerBox, self).__init__(**kwargs)
class TestApp(App):
def build(self):
return ContainerBox()
if __name__ == '__main__':
TestApp().run()
最佳答案
这个怎么样:我将 HBOX 和 VBOX 小部件更改为 BoxLayout,并将 Label 和另一个 BoxLayout 添加到 ContainerBox。看起来很像你的图
<HBoxWidget>:
AnchorLayout:
anchor_x: 'center'
anchor_y: 'center'
Image:
source: 'duck.jpg'
<VBoxWidget1>:
BoxLayout:
orientation: "horizontal"
size: [1,.25]
pos: root.pos
Label:
text: "Status : "
color: [0,84,80,19]
Label:
text: "Pending"
color: [0,84,80,19]
Widget: # Because of this widget Labels are not in the middle, its not on your drawing tough
<ContainerBox>:
orientation: 'vertical'
Label:
text: 'Label'
size_hint_y: 0.1
BoxLayout:
id: four_horizontals
orientation: 'horizontal'
HBoxWidget:
BoxLayout:
orientation:'vertical'
# One solution
#GridLayout:
# cols:1
# padding: 100
# VBoxWidget1:
# VBoxWidget1:
# VBoxWidget1:
# VBoxWidget1:
#Second Solution
BoxLayout:
#size_hint_y: 0 to 1 - it says how much you reduce height. Now its 1/3 of its parent, because there are 3 boxlayouts. if you set 0.5, it will have 1/3*0.5 and the other 2 boxlayouts takes the height which you took from this one
BoxLayout:
orientation:'vertical'
VBoxWidget1:
VBoxWidget1:
VBoxWidget1:
VBoxWidget1:
BoxLayout:
python
from kivy.app import App
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
class HBoxWidget(BoxLayout):
def __init__(self, **kwargs):
super(HBoxWidget, self).__init__(**kwargs)
class VBoxWidget1(BoxLayout):
def __init__(self, **kwargs):
super(VBoxWidget1, self).__init__(**kwargs)
class ContainerBox(BoxLayout):
def __init__(self, **kwargs):
super(ContainerBox, self).__init__(**kwargs)
class TestApp(App):
def build(self):
return ContainerBox()
if __name__ == '__main__':
TestApp().run()
其他信息:
我管理这 4 个标签的方式并不是真正正确的方式。我会给你提示如何更正确地解决它。检查https://kivy.org/doc/stable/api-kivy.uix.floatlayout.html#module-kivy.uix.floatlayout
在 BoxLayout 上,小部件会自动组织自身 - 水平或垂直,并且根据属于它们的空间大小进行缩放。使用 FloatLayout,没有任何限制,因此您可以根据需要放置标签。
一般来说,如果您的分辨率发生变化,最好使用 BoxLayouts 来解决。如果您想要更多自由,请使用 FloatLayout,但您必须自己管理小部件缩放和定位
关于python - 基维 : BoxLayout containing horizontal BoxLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54280578/
经过几个小时的(重新)搜索,我无法想出普通抽象类和使用模板模式之间的可解释区别。 我唯一看到的是: 使用抽象类时,您需要实现所有方法。但是在使用模板方法时,您只需要实现这两个抽象方法。 有人可以向我解
我正在尝试实现一种算法,该算法可找到以下形状给出的外多边形的每个单独边的对应区域。也就是说,1,2 边的相应区域是 [1,6,7,8,2],2,3 边的区域是 [2,8,3] 等等,CCW 或 CW
我正在尝试在派生 self 的 BaseController 类的任何 Controller 上自动设置一个属性。这是我的 Application_Start 方法中的代码。 UnitOfWork 属
我正在使用 mgcv 包通过以下方式将一些多项式样条拟合到一些数据: x.gam smooth$knots [1] -0.081161 -0.054107 -0.027053 0.000001
考虑以下代码: void foo(){ ..... } int main() { int arr[3][3] ; char string[10]; foo();
本书The c++ programming language有这个代码: class BB_ival_slider : public Ival_slider, protected BBslider {
是否有一个 package.json 属性可用于指定模块解析应启动的根文件夹? 例如,假设我们在 node_modules/mypackage/src/file1 中有一个安装。我们要导入的所有文件都
我正在尝试使用聚合函数来实现与 SQL 查询相同的结果: 查询语句: sqldf(" SELECT PhotoID, UserID,
我正在比较使用 LOESS 回归的两条线。我想清楚地显示两条线的置信区间,我遇到了一些困难。 我尝试过使用各种线型和颜色,但在我看来,结果仍然是忙碌和凌乱。我认为置信区间之间的阴影可能会使事情变得更清
给定这段代码 public override void Serialize(BaseContentObject obj) { string file = ObjectDataStoreFold
我正在构建某种工厂方法,它按以下方式将 DerivedClass 作为 BaseClass 返回: BaseClass Factory() { return DerivedClass(); }
当重写 class delegation 实现的接口(interface)方法时,是否可以调用通常从重写函数中委托(delegate)给的类?类似于使用继承时调用 super 的方式。 来自docum
我有一个基类 fragment (如下所示)。我在其他 3 个 fragment 类中扩展了此类,每个类都共享需要在这 3 个 fragment 中访问的相同 EditText。因此,我在基类中设置了
如何在不加载额外库的情况下在 R 中计算两个排列之间的 Kendall tau 距离(又名冒泡排序距离)? 最佳答案 这是一个 O(n.log(n)) 的实现,在阅读后拼凑而成,但我怀疑可能有更好的
情况 我创建了一个具有国际化 (i18n) 的 Angular 应用程序。我想在子域中托管不同的版本,例如: zh.myexample.com es.myexample.com 问题 当我使用命令 n
std::is_base_of 之间的唯一区别和 std::is_convertible是前者在 Base 时也成立是 私有(private)或 protected Derived 的基类.但是,您何
我创建了一个名为 baseviewcontroller 的父类(super class) uiviewcontroller 类,用于包含大多数应用屏幕所需的基本 UI。它包括一个自定义导航栏和一个“自
我是一名优秀的程序员,十分优秀!