Tag Info

New answers tagged

1

SpanFromLeft is working as designed and documented. You have specified that the first column must be aligned left and that is why your first row is aligned left. To move "AAAAA" somewhere other than what has been globally specified for the grid you need to make a specific alignment for that position: Grid[{{AAAAA, SpanFromLeft}, {aaaaa, bbbbb, ccccc}, ...


2

Grid According to the documentation, you have to explicitly define the Controls inside Grids, Columns and the like, since Manipulate has no way of figuring it out. Using a simpler example: Manipulate[code, "", Delimiter, "", {x, 0, 1}, {y, 0, 1}, "", Delimiter, "", Grid[Map[Control, {{{x, 0, 1}, {y, 0, 1}}, {{x, 0, 1}, {y, 0, ...


1

Here's a generalisation of kguler's answer for OpenerView. It allows to handle tree-like structures. Using the functions defined in my answer to Nested OpenerView controls not aligned you can emulate OpenerView controls that nest well (i.e are aligned, which is not possible using OpenerView because of the recursive way it's built, there's always an extra ...


1

Using the interesting answer of Mike, I managed to do the following which is quite easy to use. I use the vanishing sequence ##&[] instead of {}. I didn't think I would spend so much time on this display issue, but it was nonetheless quite interesting. ReleaseAllHold[expr_,firstLevel_:0,lastLevel_:Infinity] := Replace[expr, ...


2

You can roll you own to get things as you prefer. Bare bones toy code: opener[Dynamic[open_]] := EventHandler[Dynamic[If[TrueQ[open], "[-]", "[+]"]], "MouseClicked" :> (open = ! open)] open = {False, False} Dynamic[ Grid@Join[{ {opener[Dynamic[open[[1]]]], 1}, If[TrueQ[open[[1]]], {opener[Dynamic[open[[2]]]], 2}, {}], ...


2

My advice, unless it is really basic problem, do not use SpanFrom~. Usually you will face "issues" like that. Next time try with nested Grids. Like I've said, the whole layout management is broken and everyone who tried do something more complex than simple grid with automatic options will agree. This is just another example, your case works if vertical ...


4

A helper function can reduce the boilerplate somewhat: a_ // itemize[c_] := Map[Item[#, Background -> c]&, a, {-1}] DiagonalMatrix[diag // itemize[LightGray]] + PadLeft[upper // itemize[LightBlue], {-4,4}] + PadRight[lower // itemize[LightGreen], {-4,4}] // Grid


6

(*Some pre-format, starting with your element definitions *) diag = List /@ diag; upper = Join[upper, {{}}]; lower = Join[{{}}, lower]; (*code *) f[els_, col_] := Map[Item[#, Background -> col] &, els, {2}]; Grid@MapThread[Join, {f[lower, LightBlue], f[diag, LightGray], f[upper, LightRed]}]


5

Generally speaking I favour using Grid options for styling rather than using Item. For example make your matrix: MatrixForm[m = Array[Subscript[a, ##] &, {4, 4}]]; then: Grid[m, ItemStyle -> {None, None, Flatten@MapIndexed[Which[ #2[[2]] > #2[[1]], #2 -> Blue, #2[[2]] == #2[[1]], #2 -> Gray, #2[[2]] < #2[[1]], #2 ...



Top 50 recent answers are included