home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!stegosaur.cis.ohio-state.edu!mdm
- From: mdm@stegosaur.cis.ohio-state.edu (Michael Moore)
- Subject: Re: Scrollable buttons?
- Message-ID: <1992Nov17.151657.3467@cis.ohio-state.edu>
- Sender: news@cis.ohio-state.edu (NETnews )
- Organization: The Ohio State University Dept. of Computer and Info. Science
- References: <1992Nov17.102654.15449@dxcern.cern.ch>
- Date: Tue, 17 Nov 1992 15:16:57 GMT
- Lines: 77
-
- In article <1992Nov17.102654.15449@dxcern.cern.ch> trones@dxcern.cern.ch (Jostein Lodve Trones) writes:
- >
- >Any possibilities to get buttons part of a scrolling canvas?
- >
- >I have a lot of buttons to be displayed, and would like a scrollbar-feature
- >to deal with this. But buttons on a canvas is no good, is it?
- >I guess I could use rectangles on the canvas instead, but I kind of like the
- >3D appearance of the buttons.
- >
-
- You can do this. Check out the demos that came with the
- Tk distribution. I was going to use this to implement a directory
- viewer, but ran into some problems of my own with the canvas widget.
-
- Here is the code that does this sort of thing :
-
- frame .frame
-
- scrollbar .frame.scroll \
- -command ".frame.canvas yview" \
- -relief raised
-
- canvas .frame.canvas \
- -yscroll ".frame.scroll set" \
- -scrollregion {0 0 1200 10i} \
- -relief raised
-
- pack append .frame \
- .frame.scroll {left frame center filly} \
- .frame.canvas {left frame center fillx filly}
-
- pack append .\
- .frame {left frame center fillx filly}
-
- for {set i 0} {$i < 25} {incr i} {
- button .frame.canvas.button$i \
- -relief raised \
- -text "Button $i"
- .frame.canvas create window 40 [expr $i*25] \
- -window .frame.canvas.button$i
- }
-
-
- Run that through wish and watch what it does.
-
- The problem I ran into was setting up the boundaries of the canvas.
- I wanted to add and subtract buttons, and based on how many I had,
- I needed to adjust the scrollregion height of the canvas and have the
- scrollbars react accordingly.
-
- So maybe at one point in my program's execution I had 20 buttons
- lined up vertically, so my scrollregion needed to be :
-
- {0 0 200 [expr 25*20]}
-
- and then I removed them all and reconfigured it so that there
- were then 14 buttons. So I want the scroll region to be :
-
- {0 0 200 [expr 25*14]}
-
- The difficulty I encountered was that the scrollbars did not
- react to my minstrations with the scroll region. I tried doing
- a manual set command on the scrollbar but was unsuccessfull in
- sending it the proper arguments.
-
- If anyone might know of a way to do this please tell me. I am
- afraid I could not figure it out.
-
-
- -Michael
-
-
- --
- |\ Michael Delbert Moore _ /| Home : (614) 471-1937 /|
- | \ OSU Student Programmer \`o_O' Office : (614) 292-7161 / |
- | / Undergraduate CIS major ( ) Email : mdm@cis.ohio-state.edu\ |
- |/------------------------- U --------------------------------\|
-