Re: GTK app with scrolled window crashing trying to show a widget inside

2011-12-30 Thread Emmanuel Thomas-Maurin
On 12/30/2011 06:08 PM, Michael Torrie wrote:
> On 12/30/2011 05:52 AM, David Nečas wrote:
>> On Fri, Dec 30, 2011 at 01:28:32PM +0100, Moritz Renftle wrote:
>>> i want to make one of those widgets visible from
>>> another thread
>>
>> Use glib.idle_add() in that other thread to subsequently execute the
>> actual Gtk+ code in the thread running the Gtk+ main loop.
> 
> http://unpythonic.blogspot.com/2007/08/using-threads-in-pygtk.html
> 
> It used to be that threading issues came up every week on the list.  As
> David says, the recommended way is using idle_add.  However if you use
> gdk locks appropriately, on Linux you can call Gtk calls directly from
> threaded code.
> 
> http://www.pardon-sleeuwaegen.be/antoon/python/page0.html
> 
> But since this won't work so well on Windows, the idle_add() technique
> is recommended as it is most safe and most portable.

You may check out http://www.iki.fi/tml/fosdem-2006.pdf about gtk-win32
and threads.

-- 
Emmanuel Thomas-Maurin 
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK app with scrolled window crashing trying to show a widget inside

2011-12-30 Thread Michael Torrie
On 12/30/2011 05:52 AM, David Nečas wrote:
> On Fri, Dec 30, 2011 at 01:28:32PM +0100, Moritz Renftle wrote:
>> i want to make one of those widgets visible from
>> another thread
> 
> Use glib.idle_add() in that other thread to subsequently execute the
> actual Gtk+ code in the thread running the Gtk+ main loop.

http://unpythonic.blogspot.com/2007/08/using-threads-in-pygtk.html

It used to be that threading issues came up every week on the list.  As
David says, the recommended way is using idle_add.  However if you use
gdk locks appropriately, on Linux you can call Gtk calls directly from
threaded code.

http://www.pardon-sleeuwaegen.be/antoon/python/page0.html

But since this won't work so well on Windows, the idle_add() technique
is recommended as it is most safe and most portable.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK app with scrolled window crashing trying to show a widget inside

2011-12-30 Thread David Nečas
On Fri, Dec 30, 2011 at 01:28:32PM +0100, Moritz Renftle wrote:
> i want to make one of those widgets visible from
> another thread

Use glib.idle_add() in that other thread to subsequently execute the
actual Gtk+ code in the thread running the Gtk+ main loop.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GTK app with scrolled window crashing trying to show a widget inside

2011-12-30 Thread Moritz Renftle
Hi,

I'm programming a gtk-app with python and pygtk.
my app consists of a gtk.scrolledwindow and several widgets packed into
it horizontally. i want to make one of those widgets visible from
another thread (when a button is pushed on a joystick).
therefore i get the allocation of the widget and the adjustment of the
scrolledwindow and make use of the gtk.Adjustment.clamp_page function to
make sure the widget is visible on the page.

def set_focus(self):
adjust = self.scrolled_window.get_hadjustment()
x_pos = float(self.allocation.x)
x_pos_width = float(self.allocation.x + self.allocation.width)
adjust.clamp_page(x_pos, x_pos_width)

this works fine for sometime, but then some parts  of the window are not
repainted properly and the app crashes with a X Window System Error:
it's not always the same Error but one of those:
"BadDrawable", "BadIDChoice", "RenderBadPicture"...
I guess that there is a problem with gtk.main() not knowing it has to
refresh some areas of the window But I'm pretty desperate here!

Any help is very appreciated,
Moritz Renftle
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list