At 18:13 04.02.03 +0000, Gustavo J. A. M. " Carneiro wrote:
>On Tue, 2003-02-04 at 11:00, Gustavo J. A. M. Carneiro wrote:
>> On Mon, 2003-02-03 at 23:35, Andreas Kostyrka wrote:
>> > Hi!
>> > 
>> > I've been just wondering how one can display a scrolled image what is
bigger 
>> > than the screen?
>> > 
>> > DrawableArea in a Viewport in a ScrolledWindow works like a charm as
long the 
>> > image is smaller than the screen.
>> > 
>> > Any ideas? Is there some easier way then doing the scrolling myself 
>> > (DrawableArea + 2 scrollbars)?
>> 
>>   I have never tried this in python, but in C I would create a
>> DrawingArea and two scrollbars (not a DrawingArea inside a scrollend
>> window!). The image would be a GdkPixbuf. The expose event handler would
>> render part of the pixbuf to the DrawingArea's window. The part that
>> should be rendered is determined from the scrollbar adjustments (x/y
>> offsets) and DrawingArea window size (width/height). If this is not
>> possible in python, it should--file a bug report.
It is possible:

import sys, gtk

def delete_event(win, event=None):
        gtk.main_quit()

def do_display(pixbuf, name) :
        win = gtk.Window()
        win.connect("delete_event", delete_event)
        win.set_title(name)

        box = gtk.VBox()
        win.add(box)

        swin = gtk.ScrolledWindow()
        box.pack_start(swin, gtk.TRUE, gtk.TRUE, 0)

        image = gtk.Image()
        image.set_from_pixbuf(pixbuf)

        swin.add_with_viewport(image)
        win.set_default_size(600,480)

        win.show_all()

fname = sys.argv[1]
pixbuf = gtk.gdk.pixbuf_new_from_file(fname)
do_display(pixbuf, fname)

gtk.main()

>>   Alternatively, you can use bonobo.ui to insert an EOG control widget
>> to open the image you want ;)
>
>  Here's the code for this last approach. It«'s fun! ;)
>
Though a little longer the code above has the advantage of only
using plain Gtk, which makes it work under windoze as well :-)

        Hans
-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to 
get along without it.                -- Dilbert
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to