[pygtk] gtk.Entry fontsize
Leon Bogaert
leon at tim-online.nl
Tue Dec 7 04:06:43 WST 2010
The 'realize' event seems to work. Is this also actually designed to do this kind of stuff?
Regards,
Leon
________________________________________
From: pygtk-bounces at daa.com.au [pygtk-bounces at daa.com.au] on behalf of Leon Bogaert [leon at tim-online.nl]
Sent: Monday, December 06, 2010 20:29
To: Max Usachev
Cc: pygtk at daa.com.au
Subject: Re: [pygtk] gtk.Entry fontsize
Hi Max,
You example worked like a charm! But i think I'm trying to set the fontsize before it is displayed. And I can't get that working.
This doesn't work:
def on_entryTime_show(self, event):
self.entry_time.set_text('Enter new font size here')
font_description = pango.FontDescription('Lucida Sans %s' % 24)
self.entry_time.modify_font(font_description)
But this does:
def on_entryTime_button_press_event(self, widget, event):
self.entry_time.modify_font(font_description)
font_description = pango.FontDescription('Lucida Sans %s' % 24)
self.entry_time.set_text('ZzZzZz...')
How can I adjust the size when the widget is shown? Adjusting it right after gtk.builder doesn't work also.
Regards,
Leon
________________________________________
From: Max Usachev [maxusachev at gmail.com]
Sent: Monday, December 06, 2010 10:48
To: Leon Bogaert
Subject: Re: [pygtk] gtk.Entry fontsize
Hi, Leon Bogaert
This example works for me:
import gtk
import pango
def change_font_size_cb(widget, entry):
print 'changing font'
try:
font_description = pango.FontDescription('Lucida Sans %s' % int(entry.get_text()))
entry.modify_font(font_description)
except:
print 'Wrong fontsize value'
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.resize(200, 80)
window.set_title('Entry font size example')
window.connect('destroy', gtk.main_quit)
entry = gtk.Entry()
entry.set_text('Enter new font size here')
button = gtk.Button('Change size')
button.connect('clicked', change_font_size_cb, entry)
vbox = gtk.VBox()
vbox.pack_start(entry, expand=True, fill=True)
vbox.pack_start(button, expand=False, fill=True)
window.add(vbox)
window.show_all()
gtk.main()
You can find more info about pango at: http://www.pygtk.org/docs/pygtk/class-pangofontdescription.html
Br, Max.
2010/12/6 Leon Bogaert <leon at tim-online.nl<mailto:leon at tim-online.nl>>
I've been trying to edit a gtk.Enyry's fontsize by doing something like this:
gtkEntry.modify_font(pango.FontDescription('courier Medium 32'))
But the fontsize (and family) of the gtk entry doesn't change.
This works:
gtk.rc_parse_string("""
style "entryTime_style"
{
font_name="Sans Serif 24"
}
class "GtkEntry" style "entryTime_style"
""");
But I would rather copy the pango context and just change the fontsize. But I can't get that working. Does anyone has a working example?
Also, is it possible to change the (inner) background of an entry to transparent?
I'm trying to create a window like the "Timer" in the attachment.
Regards,
Leon
_______________________________________________
pygtk mailing list pygtk at daa.com.au<mailto:pygtk at daa.com.au>
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
_______________________________________________
pygtk mailing list pygtk at daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
More information about the pygtk
mailing list