Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9099883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:43:48+00:00 2026-06-17T00:43:48+00:00

I am using this code to retrieve and display an image from the web:

  • 0

I am using this code to retrieve and display an image from the web:

class Display(object):

    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect('destroy', self.destroy)
        self.window.set_border_width(10)

        self.image = gtk.Image()
        response = urllib2.urlopen('http://image.url/image.jpg').read()

        pbuf = gtk.gdk.PixbufLoader()
        pbuf.write(response)
        pbuf.close()
        self.image.set_from_pixbuf(pbuf.get_pixbuf())

        self.window.add(self.image)
        self.image.show()
        self.window.show()

    def main(self):
        gtk.main()

    def destroy(self, widget, data=None):
        gtk.main_quit()

It works, however I now want to display a text/entry box underneath the image (to retrieve the text later on). I added the following under self.image.show():

self.entry = gtk.Entry()
self.window.add(self.entry)
self.entry.show()

However, it spits out this warning then I run it, and the entry box doesn’t appear:

ee.py:31: GtkWarning: Attempting to add a widget with type GtkEntry to a GtkWindow, but as a GtkBin subclass a GtkWindow can only contain one widget at a time; it already contains a widget of type GtkImage
self.window.add(self.entry)

Not sure why it won’t let me place more than one widget, does anyone have a solution for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:43:49+00:00Added an answer on June 17, 2026 at 12:43 am

    Indeed packing is the answer.

    import gtk
    import urllib2
    class Display(object):
    
        def __init__(self):
            self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
            self.window.connect('destroy', self.destroy)
            self.window.set_border_width(10)
    
            # a box underneath would be added every time you do 
            # vbox.pack_start(new_widget)
    
            vbox = gtk.VBox()
            self.image = gtk.Image()
            response = urllib2.urlopen('http://1.bp.blogspot.com/-e-rzcjuCpk8/T3H-mSry7PI/AAAAAAAAOrc/Z3XrqSQNrSA/s1600/rubberDuck.jpg').read()
    
            pbuf = gtk.gdk.PixbufLoader()
            pbuf.write(response)
            pbuf.close()
            self.image.set_from_pixbuf(pbuf.get_pixbuf())
    
            self.window.add(vbox)
            vbox.pack_start(self.image, False)
            self.entry = gtk.Entry()
            vbox.pack_start(self.entry, False)
    
            self.image.show()
            self.window.show_all()
    
        def main(self):
            gtk.main()
    
        def destroy(self, widget, data=None):
            gtk.main_quit()
    
    a=Display()
    a.main()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to retrieve all clientID from my MCC account. I'm using this code
Here is the code I am using to try and retrieve an image from
Using this code var html='<div class=somediv></div>'; var target=document.getElementById('contentArea'); target.appendChild(html); I'm getting Uncaught Error: NOT_FOUND_ERR:
While using this code to serialize an object: public object Clone() { var serializer
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1
I was using the following code to retrieve HTML snippets from a database table
I have retrieved a jpeg image from a web service using an HTTP GET
hi i am trying to display image obtained from url (using jsoup) in a
I want to display pdf file in webview. I try using this code it
I'm using dataTables to retrieve, display and organise data from a PHP script (which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.