[Gambas-user] Scrolling text ... how to do in gambas

Werner wdahn at ...1000...
Fri Apr 25 09:29:16 CEST 2008


M0E Lnx wrote:
> I'm not sure this does what I need though...
> In this code you sent, there is a scrollview, and a text label.
> The timer shifts the scrollview's Y property to do the animation, but
> still doesn't work for me, because that would be the same as simply
> using a text label, and moving it's Y property.
>
> That I can do with a timer like in your example... but how to
> determine how tall or wide the text label has to be in order for the
> text not to get cut off the label?
>
>   
If I understand the question correctly, you want to know how many pixels 
wide and high a given text using a particular font on the screen will be.

The gb.qt Font class has the answer to that.

Example: if the name of your TextLabel is txl then

PRINT "The text is " & txl.Font.Width(txl.Text) & " pixel wide and " & 
txl.Font.Height(txl.Text) & " pixel high."

prints the width and the height when using the TextLabel's font.

One word of caution: Some fonts designers were a little sloppy in 
describing their fonts accurately, especially as far as height is concerned.

Hope I haven't answered a different question :-)

Regards,

Werner





More information about the User mailing list