TableView显示了一个不存在的列

时间:2016-11-02 14:19:23

标签: fxml

我为TableView提供了以下FXML代码,其中包含两列,但是如图所示,它显示了三个。我不明白为什么它会显示三列,我只指定了两个......任何提示?

FXML

<TableView fx:id="table"
           GridPane.columnIndex="1"
           GridPane.rowIndex="0">
    <columns>
        <TableColumn fx:id="timeColumn" text="time"/>
        <TableColumn fx:id="angleColumn" text="angle"/>
    </columns>

</TableView>

enter image description here

1 个答案:

答案 0 :(得分:1)

我发现了如何根据表的大小调整列的大小。只需将其添加到FXML中。

def split_on_uppercase(s, keep_contiguous=False):
    """

    Args:
        s (str): string
        keep_contiguous (bool): flag to indicate we want to 
                                keep contiguous uppercase chars together

    Returns:

    """

    string_length = len(s)
    is_lower_around = (lambda: s[i-1].islower() or 
                       string_length > (i + 1) and s[i + 1].islower())

    start = 0
    parts = []
    for i in range(1, string_length):
        if s[i].isupper() and (not keep_contiguous or is_lower_around()):
            parts.append(s[start: i])
            start = i
    parts.append(s[start:])

    return parts

>>> split_on_uppercase('theLongWindingRoad')
['the', 'Long', 'Winding', 'Road']
>>> split_on_uppercase('TheLongWindingRoad')
['The', 'Long', 'Winding', 'Road']
>>> split_on_uppercase('TheLongWINDINGRoadT', True)
['The', 'Long', 'WINDING', 'Road', 'T']
>>> split_on_uppercase('ABC')
['A', 'B', 'C']
>>> split_on_uppercase('ABCD', True)
['ABCD']
>>> split_on_uppercase('')
['']
>>> split_on_uppercase('hello world')
['hello world']