DataTable column added with the default `None` is at least four cells wide, though its cells are empty
まだ誰も着手していません。
評価
調査の方向性
DataTable のメソッド _get_row_renderables と _update_column_widths、および Issue で言及されている update_cell(..., update_width=True) の経路を読んでください。列サイズ調整に関する既存の DataTable テストを確認し、None セルのテストを追加してください。測定された幅が空セルの描画と一致し、報告されたテーブル幅が修正されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi! I hit this while writing generated tests against Textual's widgets. add_column on a table that already has rows fills those rows with default, which is None. The cells are drawn empty, but the column is sized as if they contained the text None.
import asyncio
from textual.app import App, ComposeResult
from textual.widgets import DataTable
class NewColumnApp(App):
def compose(self) -> ComposeResult:
yield DataTable()
def on_mount(self) -> None:
table = self.query_one(DataTable)
table.add_column("A")
table.add_row("1")
table.add_column("B") # existing rows get the default, None
async def main():
async with NewColumnApp().run_test() as pilot:
await pilot.pause()
table = pilot.app.query_one(DataTable)
for column in table.ordered_columns:
print(f"column {column.label.plain}: content_width={column.content_width}")
print("cell B:", repr(table.get_cell_at((0, 1))))
print("table width:", table.virtual_size.width)
asyncio.run(main())
Output on Textual 8.2.7 (and the same on main at 5e5b7ef):
column A: content_width=1
column B: content_width=4
cell B: None
table width: 9
I'd expect column B to be 1 wide (its label), and the table 6 wide.
_get_row_renderables draws a None cell as empty text, but _update_column_widths measures default_cell_formatter(None), which is str(None). update_cell(..., None, update_width=True) goes through the same path.
I'd suggest measuring None cells as empty in _update_column_widths, to match how they're drawn. I'm happy to send a PR.
- 主要言語
- Python
- スター
- 37.7k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Textualize/textual のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6790 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
Textualize/textual#6789 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6787 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6782 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Textualize/textual#6778 · コメント 1 件 ·
Textualize/textual の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mohanraj00/entelos#200 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
sweep
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
bketelsen/truenas-mcp#77 ·
メンテナーはふだん 1 日以内に返信
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskオープン
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
sandbox-quantum/switch#2163 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
openedx/xblock-lti-consumer#765 ·
メンテナーはふだん 1 日以内に返信