Re: print statements on console while window is running
- From: Bob Caryl <bob fis-cal com>
- To: Kathrin Hauptvogel <hauptvogel k rheinmetall-de com>
- Cc: Gtkmm-Mailinglist <gtkmm-list gnome org>
- Subject: Re: print statements on console while window is running
- Date: Fri, 18 Nov 2005 08:24:48 -0600
I don't know why you would want constant output to a console while
running a window; nevertheless, in order for your code to display a
window and also constantly output text to the console, you need it to
look like this:
<start code>
#include <gtkmm.h>
#include <iostream>
using namespace std;
using namespace Gtk;
int main(int argc, char *argv[])
{
Main kit(argc, argv);
Window window;
window.show();
while (1)
{
while(Main::events_pending())
{
Main::iteration();
}
cout << "----------------------" << endl;
}
return 0;
}
<end code>
Be advised that in the above program, closing the window will not halt
your program as written. You will have to close it from the console
using "Ctrl-c".
A better way to do this would be:
<start code>
#include <gtkmm.h>
#include <iostream>
using namespace std;
using namespace Gtk;
bool print_to_console(void)
{
cout << "----------------" << endl;
return true;
}
int main(int argc, char *argv[])
{
Main kit(argc, argv);
Window window;
// connect to the application's idle loop signal to print your console output
Glib::signal_idle().connect(sigc::fun_ptr(&print_to_console));
window.show();
Gtk::Main::run(window);
return 0;
}
<end code>
This method allows you to end your program by closing your window, and
also has the benefit of not monopolizing the computer's CPU in a tight loop.
I hope this helps.
Bob Caryl
Kathrin Hauptvogel wrote:
>Hello
>Which function I have to use to print this row "--------------------" on the
>console during my window is running
>
>#include <gtkmm.h>
>#include <iostream>
>using namespace std;
>using namespace Gtk;
>
>int main(int argc, char *argv[])
>{
>
> Main kit(argc, argv);
>
> Window window;
>
> ??????? => which function?
>
> while (1)
> {
> while(Main::events_pending())
> {
> Main::iteration();
> }
> cout << "----------------------" << endl;
>
> }
>
> return 0;
>}
>
>
>Should I use "Main::init(&argc, &argv, false);" ? If yes, which parameters I
>have to give to this function?
>
>
>Best regards
>
>Kathrin Hauptvogel
>
>_______________________________________________
>gtkmm-list mailing list
>gtkmm-list gnome org
>http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
>
>
begin:vcard
fn:Robert L Caryl Jr.
n:Caryl Jr.;Robert L
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758-2706;USA
email;internet:bob fis-cal com
title:Senior Systems Designer
tel;work:256-772-8920 x108
tel;fax:256-772-8590
tel;cell:256-527-7855
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]