Re: Fw: Re: [pygtk] setting font for gtk.Entry?

2002-11-15 Thread James Henstridge
george young wrote:


On Wed, Nov 13, 2002 at 03:54:13PM +0800, James Henstridge wrote:
 

george young wrote:

   

[pygtk-1.99.13, gtk-2.1.1, python-2.2.1, linux]
I am just trying to set the font for a gtk.Entry.  I tried:

import gtk
top = gtk.Window(gtk.WINDOW_TOPLEVEL)
top.show()
e = gtk.Entry()
sty = e.get_style().copy()
sty.font = gtk.load_font('fixed')
e.set_style(sty)
e.set_text('the rain')
e.show()
top.add(e)
gtk.mainloop()

but the font I get is some default, variable width font.  What am
I doing wrong?  [I *have* scoured the FAQ and mailing list archives...]


 

GTK 2.0 uses a new text layout system called Pango, which is why the old 
method of changing the font does not work.

If you want to change an entry field to a monospaced font, use the 
following:
 font_desc = pango.FontDescription('monospace')
 entry.modify_font(font_desc)
   


 

Whoa. Does this mean that the old commands *still work*, but produce old
results? George?
   


The above code just displays in the default font, seemingly ignoring
the set_style() statement.  It doesn't crash, but I would say that's
"not working".  It's not the "old results" one would have got from gtk+-1.x.
 

The reason that the font doesn't apply is that the GtkStyle class no 
longer has a font property (it was removed), so doing "style.font = foo" 
simply sets an attribute on the style object that isn't used for 
anything.  The widget.modify_font() method of changing the font is 
preferred with gtk 2.0.

James.

--
Email: [EMAIL PROTECTED]  | Linux.conf.au   http://linux.conf.au/
WWW:   http://www.daa.com.au/~james/ | Jan 22-25   Perth, Western Australia. 



___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Fw: Re: [pygtk] setting font for gtk.Entry?

2002-11-14 Thread george young
On Wed, Nov 13, 2002 at 03:54:13PM +0800, James Henstridge wrote:
> george young wrote:
> 
> >[pygtk-1.99.13, gtk-2.1.1, python-2.2.1, linux]
> >I am just trying to set the font for a gtk.Entry.  I tried:
> >
> >import gtk
> >top = gtk.Window(gtk.WINDOW_TOPLEVEL)
> >top.show()
> >e = gtk.Entry()
> >sty = e.get_style().copy()
> >sty.font = gtk.load_font('fixed')
> >e.set_style(sty)
> >e.set_text('the rain')
> >e.show()
> >top.add(e)
> >gtk.mainloop()
> >
> >but the font I get is some default, variable width font.  What am
> >I doing wrong?  [I *have* scoured the FAQ and mailing list archives...]
> >  
> >
> GTK 2.0 uses a new text layout system called Pango, which is why the old 
> method of changing the font does not work.
> 
> If you want to change an entry field to a monospaced font, use the 
> following:
>   font_desc = pango.FontDescription('monospace')
>   entry.modify_font(font_desc)

>Whoa. Does this mean that the old commands *still work*, but produce old
>results? George?

The above code just displays in the default font, seemingly ignoring
the set_style() statement.  It doesn't crash, but I would say that's
"not working".  It's not the "old results" one would have got from gtk+-1.x.

-- George


-- 
 I cannot think why the whole bed of the ocean is
 not one solid mass of oysters, so prolific they seem. Ah,
 I am wandering! Strange how the brain controls the brain!
-- Sherlock Holmes in "The Dying Detective"
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] setting font for gtk.Entry?

2002-11-13 Thread Christian Reis
On Wed, Nov 13, 2002 at 03:54:13PM +0800, James Henstridge wrote:
> george young wrote:
> 
> >[pygtk-1.99.13, gtk-2.1.1, python-2.2.1, linux]
> >I am just trying to set the font for a gtk.Entry.  I tried:
> >
> >import gtk
> >top = gtk.Window(gtk.WINDOW_TOPLEVEL)
> >top.show()
> >e = gtk.Entry()
> >sty = e.get_style().copy()
> >sty.font = gtk.load_font('fixed')
> >e.set_style(sty)
> >e.set_text('the rain')
> >e.show()
> >top.add(e)
> >gtk.mainloop()
> >
> >but the font I get is some default, variable width font.  What am
> >I doing wrong?  [I *have* scoured the FAQ and mailing list archives...]
> >  
> >
> GTK 2.0 uses a new text layout system called Pango, which is why the old 
> method of changing the font does not work.
> 
> If you want to change an entry field to a monospaced font, use the 
> following:
>   font_desc = pango.FontDescription('monospace')
>   entry.modify_font(font_desc)

Whoa. Does this mean that the old commands *still work*, but produce old
results? George?

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] setting font for gtk.Entry?

2002-11-12 Thread James Henstridge
george young wrote:


[pygtk-1.99.13, gtk-2.1.1, python-2.2.1, linux]
I am just trying to set the font for a gtk.Entry.  I tried:

import gtk
top = gtk.Window(gtk.WINDOW_TOPLEVEL)
top.show()
e = gtk.Entry()
sty = e.get_style().copy()
sty.font = gtk.load_font('fixed')
e.set_style(sty)
e.set_text('the rain')
e.show()
top.add(e)
gtk.mainloop()

but the font I get is some default, variable width font.  What am
I doing wrong?  [I *have* scoured the FAQ and mailing list archives...]
 

GTK 2.0 uses a new text layout system called Pango, which is why the old 
method of changing the font does not work.

If you want to change an entry field to a monospaced font, use the 
following:
 font_desc = pango.FontDescription('monospace')
 entry.modify_font(font_desc)

The "monospace" font will map to the user's preferred monospaced font.

James.

--
Email: [EMAIL PROTECTED]  | Linux.conf.au   http://linux.conf.au/
WWW:   http://www.daa.com.au/~james/ | Jan 22-25   Perth, Western Australia. 



___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


[pygtk] setting font for gtk.Entry?

2002-11-12 Thread george young
[pygtk-1.99.13, gtk-2.1.1, python-2.2.1, linux]
I am just trying to set the font for a gtk.Entry.  I tried:

import gtk
top = gtk.Window(gtk.WINDOW_TOPLEVEL)
top.show()
e = gtk.Entry()
sty = e.get_style().copy()
sty.font = gtk.load_font('fixed')
e.set_style(sty)
e.set_text('the rain')
e.show()
top.add(e)
gtk.mainloop()

but the font I get is some default, variable width font.  What am
I doing wrong?  [I *have* scoured the FAQ and mailing list archives...]

-- 
 I cannot think why the whole bed of the ocean is
 not one solid mass of oysters, so prolific they seem. Ah,
 I am wandering! Strange how the brain controls the brain!
-- Sherlock Holmes in "The Dying Detective"
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/