pygtk help

Johan johan at mailinator.com
Sun Mar 13 01:23:07 CET 2005


[x-posted to PyGTk mailing list as well]

Hello!

I'm trying to figure out how to use PYGTK to implement a rudimentary UI: 

I want to have an Image as the background, and then be able to put buttons
(eventually icons, but buttons for now)

The PyGTK FAQ (pygtk.org) has some suggestions, but they have failed
to clear up the issue.  Using their suggestions as a starting point,
I've arrived at the below.  However, it fails in that I can't seem to
place the image behind the button.  There is a FAQ entry specifically
on this at PyGTK.org, but that fails to show the pixmap (it is
obscured completely when we place a button in the Fixed widget), and
fails to allow the pixmap to be scrolled.

Can anyone show a minimal example of how I might achieve having the pixmap
as the background of the Fixed widget?  

Thanks

Johan

   def __init__(self):
        # create the main window, and attach delete_event signal to terminating
        # the application
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.connect("delete_event", self.close_application)
        window.connect("destroy", self.close_application)
        window.set_border_width(0)

        hbox= gtk.HBox()
        window.add(hbox)
        hbox.show()

        swin1 = gtk.ScrolledWindow()
        swin1.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
        swin1.set_size_request(600, 600)
        hbox.add(swin1)
        swin1.show()

        fbox1 = gtk.Fixed()  
        swin1.add_with_viewport(fbox1)
        fbox1.show()
        
        ebox1 = gtk.EventBox()  
        fbox1.put(ebox1,0,0)
        ebox1.show()

        image1 = gtk.Image()
        image1.set_from_file("/home/johan/bg.jpg")
        ebox1.add(image1)
        image1.show()
        widgetinfo( image1)
        
        b = gtk.Button("FOO")
        fbox1.put(b, 200,200)
        b.show()
        widgetinfo(b)

        ebox1.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        ebox1.connect("button_press_event", self.button_clicked)

        window.show()




More information about the Python-list mailing list