GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Dec 22, 2014 3:38 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: auto-size window with gtkmozembed
PostPosted: Sun Apr 27, 2008 1:15 am 
Offline

Joined: Sun Apr 27, 2008 12:15 am
Posts: 3
I want my gtkmozembed window to auto-size so the full webpage is showed without a scrollbar.
Does someone know how to do that?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 27, 2008 12:57 pm 
Offline

Joined: Sun Apr 27, 2008 12:15 am
Posts: 3
Code:
#!/usr/bin/python
import os, sys, gtk, gtkmozembed, PIL.Image

class Take_screenshot:
   def __init__(self, parent = None):       
      self.parent = gtk.Window(gtk.WINDOW_TOPLEVEL)
      # Initialize mozembed
      self.moz = gtkmozembed.MozEmbed()
      self.moz.show()
      print self.parent.get_allocation().height   # returns 1
      #self.moz.set_resize_mode(gtk.RESIZE_PARENT)   # tested if this changed something
      #self.parent.set_resize_mode(gtk.RESIZE_PARENT)   # tested if this changed something
      self.parent.add(self.moz)
      self.moz.load_url('http://www.google.com')       
      self.parent.show_all()
      # Connect signals
      self.moz.connect('net_stop', self.prepare_screenshot)
      self.moz.connect('size-request', self.set_size)
      self.moz.connect('size-allocate', self.set_size)
   
   def prepare_screenshot(self, data = None):   # 'Page loaded'
      sys.stdout.flush()
      gtk.timeout_add(1000, self.create_screenshot)
      #print gtk.Requisition(self.moz).height # Doesn't work (abstract widget => requisition with connect('size-request'))
   
   def set_size(self, width, height):
      print 'width: %d   height: %d'% (height.width, height.height)
      #print height # the height-parameter is a gtkmozembed object

   def create_screenshot(self):
      (x, y, width, height, depth) = self.moz.window.get_geometry()
      pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
      pixbuf.get_from_drawable(self.moz.window, self.moz.get_colormap(), 0, 0, 0, 0, width, height)
      pixbuf.save('screenshot.png', 'png')   # 'Write screenshot.png'
      gtk.main_quit()
      
Take_screenshot()
gtk.main()


this is a screenshot-script. does someone know how I can resize the window to the gtkmozembed-widget its size? (I want a screenshot of the full page)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 3:26 pm 
Offline

Joined: Sun Apr 27, 2008 12:15 am
Posts: 3
nobody?
I just don't know how to get the size of the widget, which can't be that hard I think ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group