Tk scrollbar with elided text

I am using a TkText as a base for an editor, with folding implemented by using
TkTags with the ‘elide’ option. However, the vertical scrollbar behaviour is
not what I expected. The slider within the scroller changes size depending
on whether elided text is or is not within the window.
For example:
I have several blocks of text, each block consisting of a header line that is
always visible and any number of body lines tagged so that they may be elided
as a group.

If no bodies are elided, then the scrollbar works as expected.

If all bodies are elided, then the scrollbar moves slowly as if it is actually
scrolling the elided lines and the slider changes size depending on whether a
small number or large number of elided lines are within the window.

If there is a mix of blocks, with some bodies elided and some not, then the
slider changes both size and speed depending on whether the bodies within the
window or elided or not.

I know that this must sound confusing. But perhaps some Tk user has
encountered this before. Here is my definition:

···

#-------------------------------------
# Define Vertical Scrollbar
@vbar = TkScrollbar.new(parent,
‘orient’ => ‘vertical’,
‘command’ => proc{|*args|@doc.yview(*args)}
).grid(
‘in’ => @bigGrid,
‘padx’ => 1,
‘pady’ => 1,
‘row’ => 0,
‘col’ => 2,
‘rowspan’ => 1,
‘columnspan’=> 1,
‘sticky’ => ‘news’
)

	# synchronize @doc and @lineDoc to use same scrollbar
	@doc.yscrollcommand(proc{|first, last|
		@vbar.set(first, last)
		@lineDoc.yview('moveto', first)}
		)

@doc is the main TkText and @lineDoc is a slave TkText containing line

numbers.

Albert Wagner wrote:

I am using a TkText as a base for an editor, with folding implemented by using
TkTags with the ‘elide’ option. However, the vertical scrollbar behaviour is
not what I expected. The slider within the scroller changes size depending
on whether elided text is or is not within the window.
For example:
I have several blocks of text, each block consisting of a header line that is
always visible and any number of body lines tagged so that they may be elided
as a group.

If no bodies are elided, then the scrollbar works as expected.

If all bodies are elided, then the scrollbar moves slowly as if it is actually
scrolling the elided lines and the slider changes size depending on whether a
small number or large number of elided lines are within the window.

If there is a mix of blocks, with some bodies elided and some not, then the
slider changes both size and speed depending on whether the bodies within the
window or elided or not.

I know that this must sound confusing. But perhaps some Tk user has
encountered this before. Here is my definition:

            #-------------------------------------
            # Define Vertical Scrollbar
            @vbar = TkScrollbar.new(parent,
                    'orient'  => 'vertical',
                    'command' => proc{|*args|@doc.yview(*args)}
                    ).grid(
                    'in'            => @bigGrid,
                    'padx'      => 1,
                    'pady'      => 1,
                    'row'       => 0,
                    'col'       => 2,
                    'rowspan'   => 1,
                    'columnspan'=> 1,
                    'sticky'    => 'news'
                    )

            # synchronize @doc and @lineDoc to use same scrollbar
            @doc.yscrollcommand(proc{|first, last|
                    @vbar.set(first, last)
                    @lineDoc.yview('moveto', first)}
                    )

@doc is the main TkText and @lineDoc is a slave TkText containing line

numbers.

maybe you should not use the standard ‘yview’ command of TkText, but
implement your own function
to calculate the good ‘first’ and ‘last’ values ?

jf

···


/ do you play Go? \

http://jeanfrancois.menon.free.fr/rubygo |
\ /


    \   ^__^
     \  (oo)\_______
        (__)\       )\/\
            >>----w |
            >>     >>

Hi Tk Gurus!

Task: I am trying to have a button on a canvas and to drag the button
around.

Solution 1: One way is to “draw” the button with a Rectangl Item + a label.
Problem: I don’t understand how to put the label on the top of the Rectangle
Item (is ti possible???).

Solution 2: Another way is to use a Window Itime with a Button on it.
Problem: It seems that then the Button catches all my mouse actions on it,
without informing the Canvas.

In either cases there is a bit I couldn’t get to work.

Any suggestion? If my explanation is not clear enough
I can write a small program showing the problem.

Thanks a lot!

cix

···


GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net

> maybe you should not use the standard 'yview' command of TkText, but > implement your own function > to calculate the good 'first' and 'last' values ? > > jf

Thanks, Menon. After an extensive search of Tk docs, I had about come to that
conclusion but had no confidence in my own decision.

···

On Tuesday 27 August 2002 04:16 am, MENON Jean-Francois wrote:

Mauro Cicio wrote:

Hi Tk Gurus!

hello,
I am not a Tk Guru :-> , but …

Task: I am trying to have a button on a canvas and to drag the button
around.

Solution 1: One way is to “draw” the button with a Rectangl Item + a label.
Problem: I don’t understand how to put the label on the top of the Rectangle
Item (is ti possible???).

you can choose the stacking order of the items wih the ‘raise’ method.
then use bind (‘Motion’, …) on the rectangle to move it around.

Solution 2: Another way is to use a Window Itime with a Button on it.
Problem: It seems that then the Button catches all my mouse actions on it,
without informing the Canvas.

If you need the canvas to receive events, solution 1 seems better.

jf