Re: What is the minimum number of lines to update a gui window without user clicking a button



On 08/19/2013 07:07 PM, Andrew Potter wrote:
Adding these methods to the Example class show how you can use a local
helper function. The downside is you having an extra method lying
around and remembering to use the right one in the right context; in
C++11 you could get rid of gui_append_mainloop() by using a lambda.

Edit: This uses the approach Gavin just suggested. He's right in that
I probably should have used that approach in the first place.

// Extra methods for Example 5
     /* Append to the textbuffer in a thread UNsafe manner. Should only
      * be used on the Main Loop. */
     void gui_append_mainloop(const Glib::ustring& str) {
         Glib::ustring text =  tb->get_text();
         text += "\n" + str;
         tb->set_text(text);
     }

     /* Threadsafe access to gui_append_mainloop */
     void gui_append(const Glib::ustring& str) {
         callback_dispatcher.send(sigc::bind(sigc::mem_fun(this,
&Example::gui_append_mainloop), str));
     }
// Extra methods for Example 5

Thanks again, Andrew for taking the time to diligently write code and contribute to my efforts. You asked me to comment on any problems with the code you submit.

When clicking on the close button to cancel the operation the gui window dims ad become non-responsive... locked up. That is a problem, in that some of the programs might only take seconds or minutes to complete. Some of the programs takes hours and days to complete. It's a problem if the user can't cancel the application by closing the gui window. The code that I previous posted modeled after Alan's example and Alan's example has this functionality.

I have tried to figure out how to fix the code you submitted so that it won't dim or lockup when clicking the close button, but at this time I can't.

I will continue to study the lines and try to figure out how to add the gui_print() function to the code that is currently working (Alan's Label example and my TableView example posted).

If you are able to identify why your example5 locks up when clicking the close button I'd be glad to test it and tell you if it's works.

Thanks!

-- L. James

--
L. D. James
ljames apollo3 com
www.apollo3.com/~ljames


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]