ipywidgets布局,垂直对齐框?

时间:2020-07-24 00:56:26

标签: python flexbox ipywidgets vbox hbox

我正在尝试将左侧标签与右侧列表对齐。似乎HBoxVBox都在使用flexbox,但我无法让它们正确嵌套和对齐。文档示例仅显示了简单的水平对齐方式,这对我来说也不是一件容易的事。有人做过吗?

下面的图片是我要拍摄的:

这就是我得到的:

enter image description here

代码如下:

from ipywidgets import *

t = {
    "Product List": [
        "tblProducts",
        "AMZ Listing Fees",
        "tblReferalFee",
        "tblSellingFees",
        "tblRentalBookFee",
        "tblHighVolumeFee"
        "tblRefundAdministrationFee"
    ], "AMZ FBA Fees": [
        "tblFullfillment_Fees",
        "tblMonthlyStorageFees",
        "tblLongTermStorageFees",
        "tblRemoval_Fees",
        "tblReturnsProcessingFee",
        "tblInventorySizes",
        "tblInventoryPlacementFees",
        "tblCasePackedProduct",
        "_tblDim_Const"
    ], "Enums": [
        "_Product_Enum_UnitType",
        "_tblMediaCatagoriesEnum"
    ]
}

dispBoxes = []
for k,v in t.items():
    vlayout = Layout(
        flex="5 5 auto",
        width="auto",
        halign="center"
    )
    hlayout = Layout(
        flex="1 1 auto",
        width="auto"
        #halign="center"
    )
    tblLbs = [Label(i) for i in v]
    dispBoxes.append(
        HBox([
            VBox([Label(k)], Layout=vlayout), 
            VBox(tblLbs, Layout=hlayout)
    ]))

display(
    VBox(dispBoxes)
)

0 个答案:

没有答案