Draw table in Pharo

2020-07-13 11:40发布

I’d like to display a table of values and be able to select cells.

How would I do this in Pharo Smalltalk? I’ve heard talk of Morphic widgets able to do this, but I’m still really new to Smalltalk.

1条回答
虎瘦雄心在
2楼-- · 2020-07-13 12:19

I would look into TreeModel class side examples.

I used to do that:

tree := TreeModel new.
tree openWithSpec.

tree columns: (Array 
    with: (TreeColumnModel new displayBlock: [:node | node content first asString ]; headerLabel: 'Name'; yourself)
    with: (TreeColumnModel new displayBlock: [:node | node content second asString ]; headerLabel: 'Last Name'; yourself)
    with: (TreeColumnModel new displayBlock: [:node | node content third asString ]; headerLabel: 'Age'; yourself)
    with: (TreeColumnModel new displayBlock: [:node | node content fourth asString ]; headerLabel: 'Gender'; yourself)).

then set the tree roots.

Are you in Pharo 3 or Pharo 2 ? This works in Pharo 3.

查看更多
登录 后发表回答