TK Scrollable Frame
From my experience of developing graphical user interface, the two most tedious tasks are making your windows/widgets resizable and scrollable. TK, the de facto GUI extension of of TCL (and many other scriptings such as Python), has great window managers such as pack, grid and place that make creating resizable windows/widgets really easy.
That leaves scrolling.
So I created scrollableframe some years ago to ease the tasks. The idea is it being a regular frame that responds to scollbar commands. For example, I first create a scrollable frame .sf that talk to scrollbars .hs and .vs
scrollableframe .sf -xscrollcommand {.hs set} -yscrollcommand {.vs set}
Then I create the corresponding scrollbars
scrollbar .hs -command {.sf xview} -orient horizontal
scrollbar .vs -command {.sf yview} -orient vertical
Pack (grid) them together
grid .sf -column 0 -row 0 -sticky news
grid .vs -column 1 -row 0 -sticky news
grid .hs -column 0 -row 1 -sticky news
grid columnconfigure . 0 -weight 1
grid columnconfigure . 1 -weight 0
grid rowconfigure . 0 -weight 1
grid rowconfigure . 1 -weight 0
And BAM! you have a scrollable frame. Now if I have a label with some gigantic text
label .sf.l -text "I Tried To Create Some Very Very Big Text\n\nSome Ridiculously LARGE Text\n\nTo Demonstrate Scrolling" -font [font create -family times -size 100]
All I have to do is let the scrollable frame .sf swallow it, and it will work.
.sf swallow .sf.l
scrollableframe is written in pure TCL so it is highly portable and easy to use. Full source and description is downloadable from here. Man page is available here. Feedback welcomed.
Labels: programming
0 Comments:
Post a Comment
<< Home