0

I'm using the tablelist package to show a table list (heh) in a frame, but the frame is quite small and there is a bunch of columns in the table.

I need some way to make this tablelist scrollable both horizontally and vertically.

Here is the code of my tablelist

labelframe .t.lbf -text "Search Results for: $term" -padx 0 -width 47

tablelist::tablelist .t.mlb -selectmode multiple -columns {0 "File" 0 "Name" 0 "Version" 0 "Archtectures" 0 "Summary" 0 "Type"} -stretch all -background white -width 47                

pack .t.mlb  -in .t.lbf -anchor w

place .t.lbf -x 10 -y 125
Peter Lewerin
  • 13,140
  • 1
  • 24
  • 27
Lucas Oliveira
  • 163
  • 1
  • 3
  • 15
  • I use the site of the person who created the tablelist for almost all the documentation I need. You can find out how to add scrollbars for example [here](http://www.nemethi.de/tablelist/tablelistWidget.html#std_options), plus many more options! – Jerry Nov 09 '15 at 06:51

1 Answers1

0

I've posted the basic recipe for adding scrollbars to a widget (in this case a text widget) here. The following seems to work:

toplevel .t
labelframe .t.lbf -text "Search Results for: $term" -padx 0 -width 47
tablelist::tablelist .t.lbf.mlb -selectmode multiple -columns {0 "File" 0 "Name" 0 "Version" 0 "Archtectures" 0 "Summary" 0 "Type"} -stretch all -background white -width 47 -xscroll {.t.lbf.h set} -yscroll {.t.lbf.v set}

scrollbar .t.lbf.v -orient vertical   -command {.t.lbf.mlb yview}
scrollbar .t.lbf.h -orient horizontal -command {.t.lbf.mlb xview}

# Lay them out
grid .t.lbf -sticky nsew

grid .t.lbf.mlb .t.lbf.v -sticky nsew
grid .t.lbf.h            -sticky nsew

# Tell the tablelist widget to take all the extra room
grid rowconfigure    .t.lbf .t.lbf.mlb -weight 1
grid columnconfigure .t.lbf .t.lbf.mlb -weight 1

place .t.lbf -x 10 -y 125

Note to other readers: the OP wanted to wrap the tablelist in a labelframe and then place that. Without those requirements, the task gets somewhat easier. Again, see my example in the link above: reusing it for a table list only involves replacing the text widget.

Documentation: grid, labelframe, place, scrollbar, toplevel

Community
  • 1
  • 1
Peter Lewerin
  • 13,140
  • 1
  • 24
  • 27
  • @LucasOliveira: simplified it a bit by taking out the `t.frm` frame, which became unnecessary once I gave up on packing it inside the labelframe. The new code seems to work equally well. – Peter Lewerin Nov 09 '15 at 00:52