AW: Re: [pygtk] segmentation fault after using clipboard

Bob Hepple bhepple at freeshell.org
Mon May 10 14:28:02 WST 2004


On Sat, 08 May 2004 00:41:06 -0700
John Finlay <jfinlay at moeraki.com> wrote:

> Bob Hepple wrote:
> 
> >On Fri, 7 May 2004 08:59:59 +0200
> >"Maik Hertha" <maik.hertha at berlin.de> wrote:
> >
> >  
> >
> >>:> Date: Thu, 6 May 2004 17:28:20 +1000
> >>:> From: Bob Hepple <bhepple at freeshell.org>
> >>:> Subject: Re: [pygtk] segmentation fault after using clipboard
> >>:> To: pygtk at daa.com.au
> >>:> Message-ID: <20040506172820.02c053b7.bhepple at freeshell.org>
> >>:> Content-Type: text/plain; charset="us-ascii"
> >>:> 
> >>:> Just to narrow it down a bit, it's the
> >>:> gtk.gdk.Display(os.environ["DISPLAY"]) call that causes the problem.
> >>:> 
> >>:> Anyone with an idea?
> >>:> 
> >>Why setting the DISPLAY explicit? PyGtk initializes itself with the current
> >>DISPLAY otherwise it fails.
> >>    
> >>
> >
> >Dear Maik,
> >
> >OK - I understand - but can you tell me, please, how do I reference the
> >one created in the initialization?
> >  
> >
> Try the gtk.gdk.display_get_default() function:
> 
> http://www.moeraki.com/pygtkreference/pygtk2reference/class-gdkdisplay.html#function-gdk--display-get-default
> 
> John
> 

Yes - it worked. I now do the following and the segmentation violations
go away.

		self.display = gtk.gdk.display_manager_get().get_default_display()
		self.clipboard = gtk.Clipboard(self.display, "CLIPBOARD")

I think my initial problem was calling gtk.gdk.Display() for every
copy/cut/paste operation - pygtk does not like it! Same with
gtk.Clipboard() - call it more than once and you're dead. So I call it
once at the start of the program, store the values and everything is
peachey!

Thanks for the help!


Cheers


Bob

-- 
Bob Hepple
mailto:bhepple at freeshell.org http://bhepple.freeshell.org
Public Key: http://bhepple.freeshell.org/public_keys.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20040510/f39e81ec/attachment.bin


More information about the pygtk mailing list