Hi together,
Fist: Against all common sense I post a question without having read for
a few days in this group.
However, I used groups.google and the apropriate faqs in the www but all
I could come up with were examples that do not exactly cover my problem,
or python code which also doesn’t help so much.
Here is my problem:
I want to have a GUI in a “Excel” - like way: displaying a long list of
data made up from different widgets. Since this list will grow quite
long, I need to scroll that list.
Here is what I gathered so far:
I understand that I cannot scroll a Frame (which I use to arrange my
widgets in a grid) so I wanted to use a canvas (which can be scrolled)
and paint my widgets to that.
However, now I can scroll the canvas but not the frame on top of that.
Here is the code I am unhappy with:
require 'tk'
root = TkRoot.new() { title "Canvas, Grid, and Scrollbars" }
vbar = TkScrollbar.new(root) { orient 'vert' }
canvas = TkCanvas.new(root) {
width 320
height 200
scrollregion '0 0 400 400'
}
canvas.yscrollbar(vbar)
TkGrid.grid(canvas, vbar, 'sticky'=>'ns')
TkGrid.columnconfigure(root, 0, 'weight'=>1)
TkGrid.rowconfigure( root, 0, 'weight'=>1)
TkcLine.new(canvas, 0, 0, 400, 400)
TkcLine.new(canvas, 0, 400, 400, 0)
################
commenting these lines will result in a scrollable cross on the canvas
frame = TkFrame.new(canvas).grid
for i in 1..10
button = TkButton.new(frame, 'text'=>i)
button.grid
end
################
Tk.mainloop
As a relative newbie to both TK and Ruby (I wrote a minor project with
REXML about 5 years ago but never really returned to Ruby after that),
any help would be very much appreciated.
Thanks and regards,
Andreas.