The 'realize' event seems to work. Is this also actually designed to do this 
kind of stuff?

Regards,
Leon

________________________________________
From: [email protected] [[email protected]] on behalf of Leon 
Bogaert [[email protected]]
Sent: Monday, December 06, 2010 20:29
To: Max Usachev
Cc: [email protected]
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 [[email protected]]
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 <[email protected]<mailto:[email protected]>>
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   [email protected]<mailto:[email protected]>
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to