Re: Update label immediately
- From: Rob Pearce <rob bdt-home demon co uk>
- To: gtkmm-list gnome org
- Subject: Re: Update label immediately
- Date: Sun, 20 Jul 2008 13:43:05 +0100
On Sunday 20 July 2008, Johannes Bauer wrote:
> I'm writing an application which reads from a DMM (asynchronously, I'm
> using pthreads - is that a bad idea?)
Using threads is not bad in itself, but you must keep all GTK interaction in
one thread. Basically, apart from a few Glib functions like g_idle_add, the
library is not thread-safe, merely thread-aware.
> and displays the gathered data
> graphically in a Gtk::DrawingArea and also updates the last value to a
> Gtk::Label. Events come in around every half second. The problem is, the
> label is not getting updated instantly, as I'd wish. Only when the mouse
> is moved over it, it apperas.
>
> The code that modifies the label is simple:
>
> label->set_label("foobar result");
I've done something similar except I use set_markup. This works fine, but I'm
not using threads. The update is called from a g_io_channel callback, so it's
handled by the Glib main loop.
What you probably need to do is make your DMM thread call g_idle_add when new
data arrives, then do the GUI updates in the function you pass to that. That
way the GUI stuff all lives in one Glib context.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]