Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrollable frame with just Tk

Status
Not open for further replies.

fl0ra

MIS
Jul 27, 2004
93
FR
Hi guys, it's been a long time...
Anyway, I'm trying to create a scrollable frame using only tk.
I tried with text widgets containing other widgets but the scrollbar associated with the text widget won't scroll if the widgets are displayed outside the text widgets.

here is my dirty code:
<code>
scrollbar .sbar
text .text -relief flat -yscrollcommand {.sbar set}
.sbar configure -command ".text yview"

labelframe .text.f1 -text "f1" -pady 5
labelframe .text.f2 -text "f2" -pady 5
labelframe .text.f3 -text "f3" -pady 5

.text window create end -window .f1
.text window create end -window .f2
.text window create end -window .f3


button .text.f1.b -text "ok"
button .text.f2.b -text "ok"
button .text.f3.b -text "ok"

pack .text -side left -fill both -expand yes
pack .sbar -side left -fill y
pack .text.f1.b .text.f2.b .text.f3.b -side top -expand yes
</code>


Anyone can give me a hand with that?

 
even forget the tags... :(
It's been too long...

here is goes, nicely readable
Code:
scrollbar .sbar
text .text -relief flat -yscrollcommand {.sbar set}
.sbar configure -command ".text yview"

labelframe .text.f1 -text "f1" -pady 5
labelframe .text.f2 -text "f2" -pady 5
labelframe .text.f3 -text "f3" -pady 5

.text window create end -window .f1
.text window create end -window .f2
.text window create end -window .f3


button .text.f1.b -text "ok"
button .text.f2.b -text "ok"
button .text.f3.b -text "ok"

pack .text -side left -fill both -expand yes
pack .sbar -side left -fill y
pack .text.f1.b .text.f2.b .text.f3.b -side top -expand yes
 
With only Tk, there is no such thing as a scrollable frame. However, if you just treat a text widget as a frame (and do not put anything outside of it), the scrollbars should behave nicely.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top