পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Thursday, March 30, 2017

PyGTK - Image Class

This class is also inherited from the gtk.Misc class. The object of the gtk.Image class displays an image. Usually, the image is to be loaded from a file in a pixel buffer representing gtk.gdk.Pixbuf class. Instead a convenience function set_from_file() is commonly used to display image data from file in a gk.Image widget.

The easiest way to create the gtk.Image object is to use the following constructor −
img = gtk.Image()
The following are the methods of the gtk.Image class −
  • Image.set_from_file() − This sets the image data from the contents of the file.
  • Image.set_from_pixbuf() − This sets the image data from pixmap in which the image data is loaded for offscreen manipulation.
  • Image.set_from_pixbuf() − This sets the image data using pixbuf which is an object containing the data that describes an image using client side resources.
  • Image.set_from_stock() − This sets the image data from the stock item identified by stock_id.
  • Image.clear() − This removes the current image.
  • Image.set_from_image() − This sets the image data from a client-side image buffer in the pixel format of the current display. If the image is None, the current image data will be removed.

Example

In the following program, the gtk.Image object is obtained from an image file. It is further added in the toplevel window.
import gtk
class PyApp(gtk.Window):
   def __init__(self):
      super(PyApp, self).__init__()
      self.set_title("PyGtk Image demo")
      self.set_size_request(300, 200)
      self.set_position(gtk.WIN_POS_CENTER)
      image1 = gtk.Image()
      image1.set_from_file("python.png")
      self.add(image1)
      self.connect("destroy", gtk.main_quit)
      self.show_all()
PyApp()
gtk.main()
The above code will generate the following output −
Image Demo

No comments:

Post a Comment