Re: How to update both the Console and the GTKMM gui window after running other functions
- From: "L. D. James" <ljames apollo3 com>
- To: gtkmm-list gnome org
- Subject: Re: How to update both the Console and the GTKMM gui window after running other functions
- Date: Tue, 30 Jul 2013 22:02:32 -0400
Thanks, Ian. This is a great start. I'll spend some time trying to figure out how to output to a text window or label rather than the graphics bar.
I knew this was possible. I'm very surprise it's so hard to find a natural way to do it with actual text.
After I get it done, I'll post the resolution back to the group for anyone else that is stuck.
-- L. James
--
L. D. James
ljames apollo3 com
www.apollo3.com/~ljames
On Wed, 2013-07-31 at 12:48 +1200, Ian Martin wrote:
Hi,
Have you looked at the code for the progress bar example?
https://developer.gnome.org/gtkmm-tutorial/stable/sec-progressbar.html.en
Ian.
On 31/07/13 09:33, L. D. James wrote:
> On 07/30/2013 04:53 PM, Moh B. wrote:
>> //main.cpp:
>> //-----------
>> // Look at this modified code and pay attention to the order of
>> execution and call th the functions
>> #include <gtkmm.h>
>> #include <iostream>
>>
>> using namespace std;
>>
>> int main(int argc, char* argv[])
>> {
>> Gtk::Main kit(argc, argv);
>>
>> Gtk::Window window;
>> Gtk::TextView textview;
>> Gtk::Label label;
>>
>> string mylabeltext = "This is the first line of text in my gui
>> window.\n";
>>
>> window.set_default_size(600, 360);
>> window.set_title("Gtkmm Programming - C++");
>> window.set_position(Gtk::WIN_POS_CENTER);
>>
>> label.show();
>> window.add(label);
>>
>> label.set_text(mylabeltext);
>>
>> mylabeltext += "About to run some routines...\n";
>>
>> label.set_text(mylabeltext);
>>
>> cout << "An initial line has been set to the gui window." <<
>> endl;
>> // The Gui Window is displayed
>> //==> YOURS Gtk::Main::run(window);
>> // Now my main program has performed some functions and wants to
>> update
>> // the console and the gui window.
>> cout << "Continuing after various functions and processing..." <<
>> endl;
>> //A MODIFICATION HERE '+=' instead of yours '=''
>> mylabeltext += "Showing the results of the functions and
>> processing.";
>> label.set_text(mylabeltext);
>> // AND NOW
>> Gtk::Main::run(window);
>> return 0;
>> }
>> //----------------------------------------------
>> //code end
>>
>> /////////////// Makefile ///////////////////
>> #Begin of Makefile
>> all:
>>
>> @echo " "
>> @echo " 1- Compiling..."
>> g++ -Wall -g -c *.cpp `pkg-config gtkmm-3.0 --cflags`
>>
>> @echo " "
>> @echo " 2- Linking..."
>> g++ -Wall -g *.o `pkg-config gtkmm-3.0 --libs` -o
>> Gtkmm34-popup-menu-test
>>
>> @echo " "
>> @echo " DONE!!!";
>> # @echo " "
>> chmod +x Gtkmm34-popup-menu-test
>> ls . -all
>>
>> clean:
>> rm *.o Gtkmm34-popup-menu-test
>>
>> /////////////// Makefile ///////////////////
>> #End of Makefile
>>
>
> How are you doing, Moh B.
>
> I believe you misunderstood my problem. I can output all the text out
> to the gui window without problems. However, what I'm trying to do is
> output the text after an operation has taken place. I should have put
> sleep() functions to represent some operation taking place. I want to
> give the user a status of what is taking place between operations.
>
> I updated the code to better represent this.
>
> At present I see the output at each stage on the console. However, the
> gui window isn't updated. It doesn't show anything until after all
> the functions have completed (in this case sleep() functions.
>
> In the actually program some of the functions will take a few minutes
> and some of them might take over an hour. I don't want the user to be
> left with a no status update for the entire time, or between operations.
>
> Notice how the console is output immediately. Then a sleep function.
> Then the status is updated again informing the user how long the
> function took. Then another function (in this case a sleep() function.
>
> //code begin:
> //main.cpp:
> //-----------
> // Look at this modified code and pay attention to the order of
> execution and call th the functions
> #include <gtkmm.h>
> #include <iostream>
>
> using namespace std;
>
> int main(int argc, char* argv[])
> {
> Gtk::Main kit(argc, argv);
>
> Gtk::Window window;
> Gtk::TextView textview;
> Gtk::Label label;
>
> string mylabeltext = "This is the first line of text in my
> guiwindow.\n";
>
> window.set_default_size(600, 360);
> window.set_title("Gtkmm Programming - C++");
> window.set_position(Gtk::WIN_POS_CENTER);
>
> label.show();
> window.add(label);
>
> label.set_text(mylabeltext);
>
> mylabeltext += "About to run some routines...\n";
>
> label.set_text(mylabeltext);
>
> cout << "An initial line has been set to the gui window." << endl;
>
> sleep(60); // This is the estimated time for a function to run.
> Some of them takes an hour.
> mylabeltext += "Continuing after the first fundtion that took 60
> seconds\n";
> cout << "Continuing after various functions and processing..." <<
> endl;
> label.set_text(mylabeltext);
>
> sleep(60); // This represents another stage of processes and
> operations. I'm attempting to update
> // the status to the user.
> //A MODIFICATION HERE '+=' instead of yours '=''
> mylabeltext += "Other events are taking place that has taken
> another 60 seconds\n";
> cout << "Other events have taken place" << endl;
> label.set_text(mylabeltext);
> // AND NOW
> Gtk::Main::run(window);
> return 0;
> }
> //----------------------------------------------
> //code end
>
> -- L. James
>
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]