Active Topics

 


Reply
Thread Tools
Posts: 11 | Thanked: 24 times | Joined on Apr 2010 @ Mashhad, Iran
#1
Hi,

I'm writing a calendar widget for maemo5 using python something like datetoday-home-widget and I'm almost done. the only thing remained is that I don't know how to be informed when the date changes so I can redraw the widget.

Does any body know how to implement it in python or any reference or sample code?
 
Posts: 883 | Thanked: 980 times | Joined on Jul 2007 @ Bern, Switzerland
#2
Perhaps setting an alarm at 00:00 for your app using python-alarm / libalarm could help?
http://wiki.maemo.org/Documentation/...larm_Framework

(I have no clue if 100% of that is implemented inside python-alarm.)
__________________
-Tom (N900, N810, N800)

"the idea of truly having a computer in your pocket just moved a big step closer."
 

The Following User Says Thank You to twaelti For This Useful Post:
Posts: 11 | Thanked: 24 times | Joined on Apr 2010 @ Mashhad, Iran
#3
Thanks for the reply
I found another way using signal module:
Code:
signal.signal(signal.SIGALRM, lambda signum, frame: self.update_calendar())
signal.alarm(int(86400 - (time.time() - time.mktime(time.strptime(time.strftime('%Y%m%d'), '%Y%m%d')))))
Anyway I'm new to python so any advice is greatly appreciated.

Last edited by farhadi; 2010-04-30 at 16:32.
 
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#4
You can also use gobject.timeout_add and calculate the time until midnight like above. This will call the callback in GTK+ mainloop, which might be cleaner than using Unix signals (which can happen at any point during execution). (assuming you use GTK+ - there's surely a similiar mechanism in the Qt world)
 

The Following 2 Users Say Thank You to thp For This Useful Post:
Posts: 11 | Thanked: 24 times | Joined on Apr 2010 @ Mashhad, Iran
#5
Thanks thp

I've just implemented it using gobject.timeout_add.

And one more question. How can I be informed when user manually changes date?
 
Posts: 11 | Thanked: 24 times | Joined on Apr 2010 @ Mashhad, Iran
#6
I found the solution:
Code:
import dbus
from dbus.mainloop.glib import DBusGMainLoop

DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(self.update_calendar,
dbus_interface="com.nokia.alarmd",
signal_name='time_change_ind',
path='/com/nokia/alarmd')
 

The Following 2 Users Say Thank You to farhadi For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 22:19.