title: How to integrate my infinite loop with GTK+?
body: <p>I have a Raspberry Pi3 board and I have some sensors. I wanted to make a GUI and the shortest was gtk+ and C++. For example I got continuous ECG data. That function what gave me the data is on an infinite loop. I would like to update in real time the GTK labels. Could somebody solve the problem?
  This the code:</p>
  
  <pre><code>#include &lt;gtk/gtk.h&gt;
  #include "eHealth.h"
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  //g++ -lpthread -lrt a.cpp arduPi.o eHealth.o -o a `pkg-config gtkmm-2.4 --cflags --libs`
  
  
  char c[256];
  float ECG;
  
  
  int i=0;
  float looop(){
  //here is the infinite loop
      while(1){
              ECG=eHealth.getECG();
  
          }
      return ECG;
  }
  
  
  static void button_clicked10(GtkWidget *widget, gpointer data){
      gtk_label_set_text(GTK_LABEL(data), "u clicked10");
  }
  
  static void button_clicked11(GtkWidget *widget, gpointer data){
      gtk_label_set_text(GTK_LABEL(data), "u clicked11");
  }
  
  int main(int argc, char* argv[])
  {
          gtk_init(&amp;argc, &amp;argv);
          GtkWidget *window, *label, *button, *table, *label10;
          window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
          g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
  
          table = gtk_table_new(8, 3, 10); //rows, columns, honogenous
          button = gtk_button_new_with_mnemonic("_Button");
  
          ECG=eHealth.getECG();
  
          sprintf(c,"%f", looop());
          //in this label I want to print the ECG data
          label = gtk_label_new(c);  ///(!!!)
  
          gtk_table_attach(GTK_TABLE(table), label, 0,1,0,1, GTK_FILL, GTK_FILL, 0,0);
          gtk_table_attach(GTK_TABLE(table), button, 1,2,0,1, GTK_FILL, GTK_FILL, 0,0);
  
          button = gtk_button_new_with_mnemonic("_Button 2");
          label = gtk_label_new("Hello World 2");
          gtk_table_attach(GTK_TABLE(table), label, 0,1,1,2, GTK_FILL, GTK_FILL, 0,0);
          gtk_table_attach(GTK_TABLE(table), button, 1,2,1,2, GTK_FILL, GTK_FILL, 0,0);
  
          button = gtk_button_new_with_mnemonic("_Button 3");
          label = gtk_label_new("Hello World 3");
          gtk_table_attach(GTK_TABLE(table), label, 0,1,2,3, GTK_FILL, GTK_FILL, 0,0);
          gtk_table_attach(GTK_TABLE(table), button, 1,2,2,3, GTK_FILL, GTK_FILL, 0,0);
  
  
  
          button = gtk_button_new_with_mnemonic("_Button 4");
          label = gtk_label_new("Hello World 4");
          gtk_table_attach(GTK_TABLE(table), label, 0,1,3,4, GTK_FILL, GTK_FILL, 0,0);
          gtk_table_attach(GTK_TABLE(table), button, 1,2,3,4, GTK_FILL, GTK_FILL, 0,0);
  
  
          button = gtk_button_new_with_mnemonic("_Button 5");
          label = gtk_label_new("Hello World 5");
          gtk_table_attach(GTK_TABLE(table), label, 2,3,0,1, GTK_FILL, GTK_FILL, 0,0);
          gtk_table_attach(GTK_TABLE(table), button, 3,4,0,1, GTK_FILL, GTK_FILL, 0,0);
  
  
          button = gtk_button_new_with_mnemonic("_Button 6");
          label = gtk_label_new("Hello World 6");
          gtk_table_attach(GTK_TABLE(table), label, 2,3,1,2, GTK_FILL, GTK_FILL, 0,0);
          gtk_table_attach(GTK_TABLE(table), button, 3,4,1,2, GTK_FILL, GTK_FILL, 0,0);
  
  
          button = gtk_button_new_with_mnemonic("_Button 7");
          label10 = gtk_label_new("Hello World 7");
          gtk_table_attach(GTK_TABLE(table), label10, 2,3,2,3, GTK_FILL, GTK_FILL, 0,0);
          gtk_table_attach(GTK_TABLE(table), button, 3,4,2,3, GTK_FILL, GTK_FILL, 0,0);
      g_signal_connect(button, "clicked", G_CALLBACK(button_clicked10), (gpointer)label10);
  
          button = gtk_button_new_with_mnemonic("_Button 8");
          label = gtk_label_new("Hello World 8");
          gtk_table_attach(GTK_TABLE(table), label, 2,3,3,4, GTK_FILL, GTK_FILL, 0,0);
          gtk_table_attach(GTK_TABLE(table), button, 3,4,3,4, GTK_FILL, GTK_FILL, 0,0);
  
          button = gtk_button_new_with_mnemonic("_Button 9");
          gtk_table_attach(GTK_TABLE(table), button, 0,4,4,5, GTK_FILL, GTK_FILL, 0,0);
  
  
          button = gtk_button_new_with_mnemonic("_Button 10");
          gtk_table_attach(GTK_TABLE(table), button, 0,4,5,6, GTK_FILL, GTK_FILL, 0,0);
  
          button = gtk_button_new_with_mnemonic("_Button 11");
          gtk_table_attach(GTK_TABLE(table), button, 0,4,6,7, GTK_FILL, GTK_FILL, 0,0);
          g_signal_connect(button, "clicked", G_CALLBACK(button_clicked11), (gpointer)label);
          button = gtk_button_new_with_mnemonic("_Button 10");
          gtk_table_attach(GTK_TABLE(table), button, 0,4,7,8, GTK_FILL, GTK_FILL, 0,0);
          g_signal_connect(button, "clicked", G_CALLBACK(button_clicked10), (gpointer)label);
  
          gtk_container_add(GTK_CONTAINER(window), table);
  
  
          gtk_widget_set_size_request(window, 500, 500);
          gtk_widget_show_all(window);
  
  
          gtk_main();
  
  
  return 0;
  }
  </code></pre>