-->

Draw table in Pharo

2020-07-13 11:20发布

问题:

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:

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.