예제 #1
0
def test_cell_renderer_expanding():
    '''
    One cell renderer pack started in a cell view. It should expand to
    cover the whole widget.
    '''
    cv = gtk.CellView()

    cr = gtk.CellRendererText()
    cr.set_property('background', '#ff0000')
    cv.pack_start(cr)

    win = gtk.Window()
    win.add(cv)
    win.show_all()
    win.modify_bg(gtk.STATE_NORMAL, gdk.Color('#0000ff'))

    # Cell renderer should resize now to cover the whole widget.
    win.resize(500, 500)

    utils.gtk_process_all_pending_events()
    pixbuf = utils.widget_get_rendering(win)

    # Sometimes the resize doesn't seem to happen...
    assert pixbuf.get_width() == 500
    assert pixbuf.get_height() == 500
    assert utils.pixbuf_count_pixels(pixbuf, '#0000ff') == 0
예제 #2
0
def test_spacing_of_pack_start_renderers():
    '''
    Three text cell renderers are put in a cell view using pack
    start. When the view is rendered, each of the three cell renderers
    should occupy the same amount of space.
    '''
    cv = gtk.CellView()
    crs = [gtk.CellRendererText() for x in range(3)]
    for cr, col in zip(crs, ['#ff0000', '#00ff00', '#0000ff']):
        cr.set_property('background', col)
        cr.set_property('text', 'dummy text')
        cv.pack_start(cr)

    win = gtk.Window()
    win.add(cv)
    win.show_all()

    pixbuf = utils.widget_get_rendering(win)
    reds = utils.pixbuf_count_pixels(pixbuf, '#ff0000')
    greens = utils.pixbuf_count_pixels(pixbuf, '#00ff00')
    blues = utils.pixbuf_count_pixels(pixbuf, '#0000ff')
    assert reds == greens == blues