pygtk help

Discussion in 'Python' started by Johan, Mar 13, 2005.

  1. Johan

    Johan Guest

    [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()
    Johan, Mar 13, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Mitchell

    Non-programmer needs help with PyGTK-2.0.0

    Mark Mitchell, May 28, 2004, in forum: Python
    Replies:
    6
    Views:
    409
    =?ISO-8859-1?Q?Holger_T=FCrk?=
    May 28, 2004
  2. Sridhar R
    Replies:
    0
    Views:
    288
    Sridhar R
    May 28, 2004
  3. Thierry Lam

    Help in File selector window in pygtk

    Thierry Lam, Nov 21, 2005, in forum: Python
    Replies:
    0
    Views:
    293
    Thierry Lam
    Nov 21, 2005
  4. He Jibo

    [help] how to install pygtk

    He Jibo, Apr 12, 2008, in forum: Python
    Replies:
    0
    Views:
    775
    He Jibo
    Apr 12, 2008
  5. pradeepbpin

    Help with pygtk About Dialog

    pradeepbpin, Apr 12, 2011, in forum: Python
    Replies:
    0
    Views:
    189
    pradeepbpin
    Apr 12, 2011
Loading...

Share This Page