# Problem with wrapping

**URL:** <https://www.ruby-forum.com/t/problem-with-wrapping/175007>\
**Category:** Ruby-Gnome 2\
**Created:** [September 5, 2009, 6:22pm UTC](https://www.ruby-forum.com/t/problem-with-wrapping/175007 "2009-09-05T18:22:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Sarapik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@Martin\_Sarapik](https://www.ruby-forum.com/u/Martin_Sarapik)\
**Post date:** [September 5, 2009, 6:22pm UTC](https://www.ruby-forum.com/t/problem-with-wrapping/175007/1 "2009-09-05T18:22:53Z")

</div>

I have a Gtk label to which I will be adding long texts. I’m using  
WORD\_WRAP, but the problem is it wraps the text in such a way that the  
text only fills half the area of the label.

This being the screenshot:  
[http://drop.io/raro6ka8018/asset/wrap-png](http://drop.io/raro6ka8018/asset/wrap-png)

And here’s the code:  
[http://pastie.org/607024](http://pastie.org/607024)

Any tips appreciated.

Thanks in advance,  
Martin S

---

<div class="post-metadata">

**Author:** ![Martin\_Sarapik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@Martin\_Sarapik](https://www.ruby-forum.com/u/Martin_Sarapik)\
**Post date:** [September 5, 2009, 7:27pm UTC](https://www.ruby-forum.com/t/problem-with-wrapping/175007/2 "2009-09-05T19:27:53Z")

</div>

Martin Sarapik wrote:

> I have a Gtk label to which I will be adding long texts. I’m using  
> WORD\_WRAP, but the problem is it wraps the text in such a way that the  
> text only fills half the area of the label.
> 
> Any tips appreciated.

Have you tried tinkering with Gtk::Label#width\_chars and  
Gtk::Label#width\_chars= ?

Alternatively, when you have a lot of text it might be worth going to a  
read-only TextView.

Matt.

---

<div class="post-metadata">

**Author:** ![Martin\_Sarapik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@Martin\_Sarapik](https://www.ruby-forum.com/u/Martin_Sarapik)\
**Post date:** [September 5, 2009, 7:30pm UTC](https://www.ruby-forum.com/t/problem-with-wrapping/175007/3 "2009-09-05T19:30:13Z")

</div>

Thanks for the fast reply. I’ll play around with TextView and see how it  
goes.

---

<div class="post-metadata">

**Author:** ![Martin\_Sarapik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@Martin\_Sarapik](https://www.ruby-forum.com/u/Martin_Sarapik)\
**Post date:** [September 7, 2009, 6:04pm UTC](https://www.ruby-forum.com/t/problem-with-wrapping/175007/4 "2009-09-07T18:04:06Z")

</div>

Yes, GtkTextView did the job nicely.

---

<div class="post-metadata">

**Author:** ![Martin\_Sarapik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@Martin\_Sarapik](https://www.ruby-forum.com/u/Martin_Sarapik)\
**Post date:** [September 7, 2009, 10:32am UTC](https://www.ruby-forum.com/t/problem-with-wrapping/175007/5 "2009-09-07T10:32:10Z")

</div>

It’s interesting. Based on your program, here’s what I tried:

[http://pastebin.ca/1556905](http://pastebin.ca/1556905)

Console output is:

label size request: 408x1462  
label size allocation: 600x300

The label requires 408x1462 for display, based on its text. Then, when  
it’s allocated more width (600 instead of 408), it won’t use it to  
reprocess the wrap and use the larger width…

[http://zarb.org/~gc/t/gtl.png](http://zarb.org/~gc/t/gtl.png)

I am not expert in Gtk Allocation enough to know if this behaviour is  
normal or bad (or worse).

Anyway, the other advice to use a GtkTextView when in need to display  
more than “labels” is also my choice.

On Sat, Sep 5, 2009 at 6:22 PM, Martin Sarapik[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Any tips appreciated.  
> ruby-gnome2-devel-en mailing list  
> removed\_email\_address@domain.invalid  
> [ruby-gnome2-devel-en List Signup and Options](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

–  
Guillaume C. - [Guillaume Cottenceau](http://zarb.org/~gc/)
