On Wed, Jun 18, 2008 at 9:27 AM, Robert Boehne <[EMAIL PROTECTED]> wrote:

> When I run your example, I see that same box.  This leads me to believe it
> is a setup issue, can anyone point me in the direction of where to look?

Sorry, attached the wrong code <duh>
# -*- coding: utf-8 -*-
from __future__ import division

import pygtk
pygtk.require('2.6')
import gtk
from gtk import gdk
import pango


win = gtk.Window()
win.show()
vbox = gtk.VBox()
vbox.show()
win.add(vbox)

figsize = 4,4
dpi = 200

def draw(widget):

    gc = widget.window.new_gc()

    context = widget.create_pango_context()
    layout  = widget.create_pango_layout(unicode('Développés et fabriqués', 'latin-1'))

    fontsize = 12  # points
    scale = dpi/72.0

    desc = pango.FontDescription('Bitstream Vera Sans, normal 12')
    desc.set_size(int(scale*fontsize)*1024)
    layout.set_font_description(desc)
    inkRect, logicalRect = layout.get_pixel_extents()
    l,b,w,h = inkRect
    #l,b,w,h = logicalRect
    x, y = 100, 100
    widget.window.draw_rectangle( gc, 0, l+x, y+b, w, h)
    widget.window.draw_layout(gc, x, y, layout=layout)


def configure_event(widget, event):
    global pixmap
    pixmap = gtk.gdk.Pixmap(widget.window, 500, 500)
    draw(widget)
    return gtk.TRUE

def expose_event(widget, event):
    draw(widget)
    return gtk.TRUE

da = gtk.DrawingArea()
da.connect('configure_event', configure_event)
da.connect('expose_event', configure_event)

da.set_size_request(figsize[0]*dpi, figsize[1]*dpi)


da.show()
vbox.pack_start(da, gtk.TRUE, gtk.TRUE)

def byebye(button):
    gtk.mainquit()

button = gtk.Button('Quit')
button.show()
vbox.pack_start(button, gtk.TRUE, gtk.TRUE)
button.connect('clicked', byebye)

gtk.main()
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to