# Some simple question

**URL:** <https://www.ruby-forum.com/t/some-simple-question/205235>\
**Category:** Ruby-Gnome 2\
**Created:** [April 1, 2011, 2:47pm UTC](https://www.ruby-forum.com/t/some-simple-question/205235 "2011-04-01T14:47:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 1, 2011, 2:47pm UTC](https://www.ruby-forum.com/t/some-simple-question/205235/1 "2011-04-01T14:47:46Z")

</div>

Dear all

Sorry to ask this, I know I can find some of answers in doc if I dig  
deeper  
But I’m tight on schedule, So please reply if you are willing to

1. How to change font size in label and entry widget ?
2. How to differentiate color in treeview row (odd grey, even white or  
vice  
versa) ?
3. How to make anything typed on entry become uppercase ?
4. How to right align column in treeview? also center-align?

I’m making a POS program  
and it’s been partially implemented (at my own store)  
that’s why I need this fast

Regards,  
Hendra

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [April 1, 2011, 6:31pm UTC](https://www.ruby-forum.com/t/some-simple-question/205235/2 "2011-04-01T18:31:24Z")

</div>

2011/4/1 hendra kusuma [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Dear all
> 
> Sorry to ask this, I know I can find some of answers in doc if I dig deeper  
> But I’m tight on schedule, So please reply if you are willing to
> 
> 1. How to change font size in label and entry widget ?

Take a look at [http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk::Label](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk::Label)  
My tests:  
Gtk::Label#set\_markup(‘toto’) works  
Gtk::Label#set\_markup(‘toto’) does not work  
(Is it a bug??)

> 1. How to differentiate color in treeview row (odd grey, even white or vice  
> versa) ?

[http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview-renderer-bold](http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview-renderer-bold)

> 1. How to make anything typed on entry become uppercase ?

You can convert entry text to uppercase when it is activated.  
Or do you really need to convert each letter when it is typed ?

> 1. How to right align column in treeview? also center-align?

[http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk::CellRendererText#alignment%3D](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk::CellRendererText#alignment%3D)

> 

–  
Vincent C.

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [April 1, 2011, 9:06pm UTC](https://www.ruby-forum.com/t/some-simple-question/205235/3 "2011-04-01T21:06:40Z")

</div>

hendra kusuma wrote in post #990384:

> 1. How to change font size in label and entry widget ?

it’s easy enough to implement a file chooser dialog where you can  
choose the font and size…  
[http://ruby-gnome2.sourceforge.jp/de/hiki.cgi?Gtk::FontSelectionDialog](http://ruby-gnome2.sourceforge.jp/de/hiki.cgi?Gtk::FontSelectionDialog)

and a color selection dialog…  
[http://ruby-gnome2.sourceforge.jp/it/hiki.cgi?Gtk::ColorSelectionDialog](http://ruby-gnome2.sourceforge.jp/it/hiki.cgi?Gtk::ColorSelectionDialog)

…and then use them in your pango markup… for example:

def fontSelect  
d = Gtk::FontSelectionDialog.new  
d.set\_font\_name(@font) if @font != nil  
response = d.run  
if response == Gtk::Dialog::RESPONSE\_OK  
@font = d.font\_name

# fontdesc = Pango::FontDescription.new(@font)

# @fontBtn.modify\_font(fontdesc)

# @fontBtn.set\_label(@font) # these are specific to my app

end  
d.destroy  
end #fontSelect

def fontColorSelect  
d = Gtk::ColorSelectionDialog.new  
sel = d.colorsel

# sel.set\_previous\_color(@fC)

# sel.set\_current\_color(@fC)

sel.set\_has\_palette(true)  
response = d.run

if response == Gtk::Dialog::RESPONSE\_OK  
@fR = sel.current\_color.red  
@fG = sel.current\_color.green  
@fB = sel.current\_color.blue  
@fC = Gdk::Color.new(@fR, @fG, @fB)  
@fColor = @fC.to\_s  
@fcsample.modify\_bg(Gtk::STATE\_NORMAL, @fC)  
end  
d.destroy  
end #fontColorSelect

## and then later…

info = “blargh”  
@infoTxt.set\_markup(%Q[#{info}])

> 1. How to make anything typed on entry become uppercase ?

entry = Gtk::Enty.new

# do whatever you’re going to do…

entry.editing\_done  
entrytext = entry.text.upcase

-j

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [April 2, 2011, 3:34am UTC](https://www.ruby-forum.com/t/some-simple-question/205235/4 "2011-04-02T03:34:39Z")

</div>

Dear all,  
Thanks for replying

Those markup are good. But I thing that’s only applicable to label (or  
am I  
missing something here?)  
How about font size for entry? Thanks

for number 3  
I would like to convert each letter when it is typed

I’m checking all your suggestion now  
Thanks

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [April 2, 2011, 4:16am UTC](https://www.ruby-forum.com/t/some-simple-question/205235/5 "2011-04-02T04:16:50Z")

</div>

hi hendra -

> How about font size for entry? Thanks

a quick look at “Gtk::Entry.instance\_methods” shows me a #modify\_font  
method… not sure, but this would probably look something like

Gtk::Entry#modify\_font(Gtk::STATE\_NORMAL,##myfont##)

where ##myfont## is a font\_description with family and size specified  
(all simplified with the FontSelectionDialog…)

as for number 3, why do you need to convert while typing? do you have  
background processes running based on each letter? you can convert it  
to uppercase with a simple String#upcase immediately after entering  
it…

good luck -

-j

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [April 2, 2011, 5:04am UTC](https://www.ruby-forum.com/t/some-simple-question/205235/6 "2011-04-02T05:04:40Z")

</div>

Vincent C. wrote in post #990422:

> My tests:  
> Gtk::Label#set\_markup(‘toto’) works  
> Gtk::Label#set\_markup(‘toto’) does not work  
> (Is it a bug??)

pango markup for some reason specifies font size in 1024’s of a point  
(no clue why…) making “32” much to small to show. you can sidestep  
that by using a partial font\_description, though… both of the  
following work:

Gtk::Label#set\_markup(%Q[blargh])

Gtk::Label#set\_markup(%Q[blargh])

[http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup](http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup)

-j

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [April 2, 2011, 5:44am UTC](https://www.ruby-forum.com/t/some-simple-question/205235/7 "2011-04-02T05:44:31Z")

</div>

On Sat, Apr 2, 2011 at 11:27 AM, Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > Gtk::Label#set\_markup(‘toto’) works
> > 
> > Gtk::Label#set\_markup(%Q[blargh])
> > 
> > [http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup](http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup)
> 
> Use Pango::SCALE for it:
> 
> Gtk::Label#set\_markup(“\<span size="#{32 \* Pango::SCALE}"\>toto”)

This whole panga thing is new to me, never touch it before. Thanks  
It will run on windows right? I make the code on ubuntu but must deploy  
on  
windows

as for number 3, this is a matter of taste  
my old version using delphi behave like that so users want it that way  
🙂  
and no, that entry don’t process any other thing

also for treeview cell coloring I already use rules hint. on linux it  
gives  
me grid, but it doesn’t show on windows. I wonder why. Other suggestion?

on treeview column right-alignment, anyone care to give example?  
right now I really appreciate anything I can copy paste 😃

Thanks guys

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [April 2, 2011, 4:23pm UTC](https://www.ruby-forum.com/t/some-simple-question/205235/8 "2011-04-02T16:23:34Z")

</div>

On Sat, Apr 2, 2011 at 11:43 AM, hendra kusuma  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > > that by using a partial font\_description, though… both of the
> 
> and no, that entry don’t process any other thing
> 
> also for treeview cell coloring I already use rules hint. on linux it gives  
> me grid, but it doesn’t show on windows. I wonder why. Other suggestion?
> 
> on treeview column right-alignment, anyone care to give example?  
> right now I really appreciate anything I can copy paste 😃

Pango ALIGN\_RIGHT not working  
found how to right-align column in treeview on google

cell\_renderer.xalign = 1.0

This works, but what is this?

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [April 2, 2011, 5:28am UTC](https://www.ruby-forum.com/t/some-simple-question/205235/9 "2011-04-02T05:28:31Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] Some simple question” on Sat, 02 Apr 2011  
05:04:40 +0200,  
jake kaiden [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> that by using a partial font\_description, though… both of the  
> following work:
> 
> Gtk::Label#set\_markup(%Q[blargh])
> 
> Gtk::Label#set\_markup(%Q[blargh])
> 
> [http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup](http://ruby-gnome2.sourceforge.jp/hiki.cgi?pango-markup)

Use Pango::SCALE for it:

Gtk::Label#set\_markup(“\<span size="#{32 \*  
Pango::SCALE}"\>toto”)

## Thanks,

kou
