JohnEarnest / Decker

A multimedia sketchpad
MIT License
1.09k stars 56 forks source link

Question on Grid #22

Closed indrajithk closed 2 years ago

indrajithk commented 2 years ago

Again, it is a how-to question. Once the Grid widget is chosen, how to populate the grid with entries ? The document is not very clear on how to do it. It talks about format string, but don't say how to add rows and columns.

A workaround is to create a csv file and DnD into the card. But, it is not efficient when you have to modify it inside Decker. Any help in this regard will be appreciated.

JohnEarnest commented 2 years ago

If you create a new grid, it will contain an empty table with no rows or columns.

The simplest way to create a set of columns is to select the grid in "Interact" mode and choose "Edit -> Query...". You can then enter a Lil query (or any expression which produces a table), "Run" it to confirm the results are as desired, and then click "Apply" to store the result in the grid.

An insert query is an easy way to produce new tables from scratch. For example, a table with two columns and no rows:

insert
 a:()
 b:()
into 0

Or a table with three columns and three rows:

insert
 name:  "Alice","Bob","Charlie"
 age:   23,25,17
 hobby: "cryptography","espionage","birdwatching"
into 0

Once a table has the appropriate columns, you can add and remove rows from the Edit menu when it is selected, and double-click cells to edit them.

indrajithk commented 2 years ago

Works like a charm! Thx