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



Hi, Alan.  I've worked on the last example in many ways.  The program compiles without errors and shows a gui window, but nothing is ever output to the window.

If you have experimented up to this point and found a method, can you help me with an example.

I'll remind you that I'm embarrassed about being so novice about classes, threads, signals, dispatchers and some of the other terminology.  But when I see something that works it'll be a learning experience for me to learn the names and functions of the lines of text.

Please forgive me for being so verbose.  I'm trying to be clear while at the same time use as few words as possible.

Thanks!

// c++ 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)
Gtk::Window window;
void myprocess1();

window.set_title("Gtkmm Programming - C++");
window.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;
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);
  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

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

-- L. James

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

On Wed, 2013-07-31 at 16:49 -0700, Alan Mazer wrote:
Okay.  You're close.  Let me know if you want help.  Otherwise I'll let you figure it out on your own :-).

-- Alan



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