2013-08-11 02:30, L. D. James skrev:
Thanks, Chris. I may end up using Glib::spawn_async (but I it doesn't appear to be a call for updating text to a gui window) and I may end up using Glib::signal_io().connect()) to send text to the gui window. This is the first time i see these as ways of updating the gui.You seem convinced that the shorter a program is, the easier it is to understand it. I'm not so sure. I get the impression that you don't understand how a GUI system works, Much work is going on behind the scene. An example: When you call m_TextView.get_buffer()->set_text("Hello world!"), the text is stored somewhere, the TextView is invalidated (marked that it shall be redrawn), but the text is not written to the screen. That's done later, after your function has returned. If your window is later hidden because another window is moved on top of it, and your window is then still later made visible again, the TextView is once again redrawn without your function being called. It your function contains a long calculation, taking minutes or hours, your window is not redrawn. The best way to avoid that is, like several people have mentioned, to create a separate thread of execution for the long calculation. You are trying to learn two interesting but rather difficult techniques, GUI programming and multi-threading, at the same time and mixed up. Well, GUI programming is not always difficult. It becomes more difficult when your application also needs multi-threading. I wish I could point out some good web sites for you to start with. I'm sure there are some, but I don't know where. There is of course the gtkmm tutorial, https://developer.gnome.org/gtkmm-tutorial/stable/, but it does not explain what's going on behind the scene in a GUI system. I once learnt that by reading "Programming Windows" by Charles Petzold. It's an excellent introduction to MS Windows programming in C, but it's not the book to read when you want to learn gtkmm. The description of glib's main event loop, https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html, is definitely not written for beginners. Since you dislike buttons, can't you remove all buttons and the button box from my example program? Remove all code that has anything to do with the buttons except // Start a new worker thread. m_WorkerThread = Glib::Threads::Thread::create( sigc::bind(sigc::mem_fun(m_Worker, &ExampleWorker::do_work), this)); which you move to ExampleWindow's constructor. And you can change the loop in ExampleWorker::do_work() to make it run forever, if you like. Kjell |