Re: How to update both the Console and the GTKMM gui window after running other functions



Thanks, Alan.  I'm all excited about getting close.

I was thinking the problem existed because I was trying to use label instead of some of the other widgets such as textview, of which I'm currently studying.

I appreciate all your support and input.  I'm sure by Monday I'll understand even more and be able to follow more academically all the lines of the samples you provide.

I actually have 10 project directories of code in this goal.  So my working and exploring textview won't loose the development point of with the label method.

I'm sure what I learn about threading will be a plus of which will help me to optimize my years of crude programs that I already use.

I'm glad that you can see progress and report that we're nearing it.

Enjoy your weekend!

-- L. James

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

On Sat, 2013-08-03 at 15:00 +0000, Mazer, Alan S (389M) wrote:
I haven't forgotten your end goal. You need threading to get there if you want the GUI to be responsive while the long computations are taking place. I sent you a little sample code already but I can show you how it fits together on Monday. There's not much left to be done.

Sent from my Android phone using TouchDown (www.nitrodesk.com)

-----Original Message-----
From: L. D. James [ljames apollo3 com]
Received: Friday, 02 Aug 2013, 5:45pm
To: Mazer, Alan S (389M) [Alan S Mazer jpl nasa gov]
CC: gtkmm-list gnome org [gtkmm-list gnome org]
Subject: Re: How to update both the Console and the GTKMM gui window after running other functions

Thanks.

I forgot to remind you of important details.  For one I forget to mention that the “sleep(10)” function represented a function that is processing such as searching all the network drives for a string and doing other chores that might take up to three hours or more.

Then when it gets back it's supposed to update the gui screen and console.

I thought I had tested run(mylabel) and had problems.  I should have left the line there commented out.  But I'm glad to see that your update prints.  However, it prints all the text at once.  It doesn't print anything after a function.

I uncommented the sleep(10) function.  There is no window until the function ends.  Then everything is printed.

So if the user ran the program he would have no idea what is happening until three hours later.  He might try to run the application numerous times to get something on the screen and really cause problems.

My objective is to immediately print something on the gui.  Then run functions.  The print and update to the gui, the same way you see the console output updated.

And yes.  I appreciate anything I can learn about those terms (threading, etc), especially if this is what is going to be needed to update what is on the gui.

I'm adding what might be a clearer description of what I'm trying to do to your new code that prints.

Most likely the threading is where the sleep() and myprocess1() functions should be.

// code begin
// -------------------------------------------
#include <gtkmm.h>
#include <iostream>

using namespace std;

class myLabel: public Gtk::Window
{
// blah blah blah
public:
myLabel();
   virtual ~myLabel();

protected:
Gtk::Label m_label;
string labeltext;
string newtext;
};

myLabel::myLabel() : m_label("Hello World")
{
// myLabel.set_text("hello"); // This line gives errors (*1)
void myprocess1();

set_title("Gtkmm Programming - C++");
add(m_label);

m_label.show();
labeltext = "About to preform a number of processes.\n";
labeltext += "Each process may take up to three hours.\n";
labeltext += "Please carry your daily chores and wait.\n";
cout << labeltext << endl;
m_label.set_text(labeltext);

sleep(10); // Back from a three hour function
newtext = "Back from a three hour function\n";
labeltext += newtext;
m_label.set_text(labeltext);
cout << newtext << endl;

myprocess1();

cout << "Window should be displayed" << endl;
}
myLabel::~myLabel()
{
}
void myprocess1()
{
cout << "Running another process that is generating output..." << endl;
}

int main(int argc, char* argv[])
{
     Gtk::Main kit(argc, argv);

     myLabel mylabel;
     Gtk::Main::run(mylabel);
     return 0;
}
// -------------------------------------------
// code end

-- L. James





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