Reply
Thread Tools
Posts: 187 | Thanked: 41 times | Joined on May 2010
#1
Hi guys , i am trying to change the sms_counter_widget to use a different logic to account the SMSs. Everything is working fine but i'd like some help to make the python table CLICKABLE. So i can click it and it would call update_widget()

I have no idea how to do it.; Could anyone help me ?

Bellow is the widget ui code.
Code:
class SMS_widget(hildondesktop.HomePluginItem):
        def callback_function(self, button, data=""):
                self.update_widget()

        def __init__(self):
                hildondesktop.HomePluginItem.__init__(self)
                self.set_settings(False)
                self.all = sms_counter()
                self.table = gtk.Table(1,2,False)

		self.this_month_sent = gtk.Label('0')
                self.table.attach(self.this_month_sent, 1, 2, 1, 2)

                self.sent_title = gtk.Label('Sent SMSs: ')
                self.box_for_sent = gtk.HBox()
                self.box_for_sent.pack_end(self.sent_title, False, False)
                self.table.attach(self.box_for_sent, 0, 1, 1, 2, xpadding=6)
                self.update_widget()
                self.table.show_all()
                self.add(self.table)

                self.listen()

	def update_widget(self, dummy1="", dummy2="", dummy3="", dummy4="", dummy5=""):
                 self.all.update_counters()
                 self.this_month_sent.set_text(str(self.all.sent_messages))

        def listen(self):
                DBusGMainLoop(set_as_default=True)
                self.bus = dbus.SystemBus()
                self.bus.add_signal_receiver(self.update_widget, path='/com/nokia/phone/SMS', dbus_interface='Phone.SMS', signal_name='IncomingSegment')
                self.bus.add_signal_receiver(self.update_widget, path='/com/nokia/phone/SMS/ba212ae1', dbus_interface='com.nokia.csd.SMS.Outgoing', signal_name='OutgoingSegment')
So , how could i make that widget clickable ?
If it is not possible, how could i make it update on "switching desktop" for example ?
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#2
Originally Posted by colchaodemola View Post
If it is not possible, how could i make it update on "switching desktop" for example ?
connect to "notify::is-on-current-desktop"
 
Posts: 187 | Thanked: 41 times | Joined on May 2010
#3
Originally Posted by nicolai View Post
connect to "notify::is-on-current-desktop"
I have no idea how to do this... Could you give me some python code ?
 
Posts: 56 | Thanked: 31 times | Joined on Jul 2008 @ Austria
#4
Hm... is that a trick question?

self.connect("notify::is-on-current-desktop", self.callback_function)

or without the scaffolding:
self.connect("notify::is-on-current-desktop", lambda *args, **kwargs: self.update_widget())

and as for making anything clickable, just put it into a Button
button = gtk.Button()
button.add(self.table)
and connect to its "clicked"
button.connect("clicked", whatever)
The button can also be made not look like a button (seems fashionable nowadays) by:
button.set_relief(gtk.RELIEF_NONE)
or some do
button.set_relief(gtk.RELIEF_HALF)
a few leave it alone.

http://wiki.maemo.org/PyMaemo/HildonDesktop

Last edited by dannym; 2010-08-24 at 21:59.
 

The Following User Says Thank You to dannym For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 00:54.