[pygtk] loading a glade window with user-preferred size and location

Steve McClure smcclure at racemi.com
Fri Feb 24 05:42:55 WST 2006


On Fri, 2006-02-24 at 00:25 +1100, John Pye wrote:
> Hi Steve,
> 
> Sorry for the delay getting back to you following your suggestions on 
> this. I tried what you suggested and removed the default size 
> specificiation in Glade. It still didn't work: the window shows up very 
> small (about 200x300 px) then is resized to my stored-preferences size 
> during the next refresh.
> 
> What did you mean by "Set the size and position after the window is 
> realized but before is it mapped?" -- how can I do that? I basically 
> just have the following:
> 
> >         glade = gtk.glade.XML(GLADE_FILE,"browserwin")
> >
> >         self.window = glade.get_widget("browserwin")
> >
> >         if not self.window:
> >             raise RuntimeError("Couldn't load window from glade file")
> >
> >         _display = self.window.get_screen().get_display().get_name()
> >         _geom=self.prefs.getGeometrySizePosition(_display,"browserwin")
> >         if _geom:
> >             self.window.resize(_geom[0],_geom[1])
> >             self.window.move(_geom[2],_geom[3])
> >         
> >         self.window.connect("delete_event", self.delete_event)

Currently, I'm stuck on Gtk 1.2 so this might not directly apply but
something very similar should work.

I use a callback for the "realize" signal for my dialogs.  Then if the
user has preference data stored for that dialog I get it can do:

dialog.set_usize(width, height)

all of this is done in the realize handler.  I use a handler for the
"configure_event" in order to gather that preference data.

Hope that helps,
Steve

> 
> 
> Cheers
> JP
> 
> Steve McClure wrote:
> 
> >On Fri, 2006-02-10 at 14:49 +1100, John Pye wrote:
> >  
> >
> >>Hi all
> >>
> >>The following doesn't seem to work for me unless I switch the
> >>'set_default_size' to 'resize'. Is this because of something I'm doing
> >>with Glade?
> >>
> >>
> >>        self.window = glade.get_widget("browserwin")
> >>
> >>        _display = self.window.get_screen().get_display().get_name()
> >>
> >>        # my own routine for the previously saved window position....
> >>        _geom=self.prefs.getGeometrySizePosition(_display,"browserwin")
> >>
> >>        if _geom:
> >>            self.window.set_default_size(_geom[0],_geom[1])
> >>            #self.window.resize(_geom[0],_geom[1])
> >>            self.window.move(_geom[2],_geom[3])
> >>
> >>
> >>The problem with this approach is that the window first shows up at the
> >>Glade-specified size, then is resized later to the user-preferenced
> >>default size. So somehow I'm failing to 'set_default_size' before the
> >>window is first drawn.
> >>
> >>Does this mean I can't use Glade to create a user-preference-sized
> >>window? Is there a better way of doing all this?
> >>    
> >>
> >
> >Don't set the size in glade?
> >
> >Set the size and position after the window is realized but before is it
> >mapped?
> >
> >  
> >
> >>Cheers
> >>JP
> >>
> >>    
> >>
-- 
Steve McClure                                           Racemi
email: smcclure at racemi.com                              380 Interstate North Pkwy, SE
voice: 404-892-5850                                     Suite 250
fax: 404-892-7215                                       Atlanta, GA 30339
                                                        http://www.racemi.com



More information about the pygtk mailing list