RE: Display date and time using gtkmm2.4



Thanks Madhusudan...

Your pointers were great for me to start off. I was looking for the
corresponding method in gtkmm.

For those new like me out there... this is what I did:

Called:

Glib::signal_timeout().connect(sigc::mem_fun(*this,&className::periodicTask),1000);

bool className :: periodicTask(){
        time_t rawtime;
        struct tm * timeinfo;
        string date;

        time ( &rawtime );
        timeinfo = localtime ( &rawtime );
        
        date = asctime(timeinfo);
        m_date.set_text("date:"+date);
        return true;
}

returning true alone will get the clock ticking. With false, it just
displays once and m_date is not updated.

Hope this helps somebody someday.

Thanks
Sirisha



On Thu, 2006-12-14 at 10:39 +0530, Madhusudan E wrote:
Hi, 
You may use

For ex:

g_timeout_add_full(G_PRIORITY_DEFAULT,1000, periodicTask, NULL,
(GDestroyNotify)go_to_timeout);

Where in , the 'periodicTask' callback will be called every 1 sec (1000
msec),
Within this callback you can use, time_t to get the time current time.
Update your window and display.

I hope this helps.

Rgds,
Madhusudan.

 

-----Original Message-----
From: gtk-app-devel-list-bounces gnome org
[mailto:gtk-app-devel-list-bounces gnome org] On Behalf Of SIRISHA
MUPPAVARAPU
Sent: Thursday, December 14, 2006 2:03 AM
To: gtk-app-devel-list gnome org
Subject: Display date and time using gtkmm2.4

Hi All

In my project, I need to display the date time on the window as long as
the application is running. Kind of real time display of date,time on
the window. I can use time_t from time.h and obtain the date and time.
But, how do I make is real time? I am using libgtk2.8 and libgtkmm 2.4.

I searched all over the net and couldn't find any solution. All your
suggestions are highly appreciated. I am pretty new to GTK programming
and I come from Java/C# background. Hope someone there can help me with
a seemingly simple problem.

Thanks in advance
Sirisha
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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