GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

auto-size window with gtkmozembed

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
woutable



Joined: 27 Apr 2008
Posts: 3

PostPosted: Sun Apr 27, 2008 1:15 am    Post subject: auto-size window with gtkmozembed Reply with quote

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
Back to top
woutable



Joined: 27 Apr 2008
Posts: 3

PostPosted: Sun Apr 27, 2008 12:57 pm    Post subject: Reply with quote

Code: (Python)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

#!/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)
Back to top
woutable



Joined: 27 Apr 2008
Posts: 3

PostPosted: Tue Apr 29, 2008 3:26 pm    Post subject: Reply with quote

nobody?
I just don't know how to get the size of the widget, which can't be that hard I think ...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP