maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Python Statusbar applet possible? (https://talk.maemo.org/showthread.php?t=22857)

tz1 2008-08-14 19:38

Python Statusbar applet possible?
 
I've seen it done for the home area, but I can't find a hello-world applet and my attempts at modifying the python code for the home example hasn't worked so far.

Is it even possible to create a python statusbar applet, and if so, is there an example source/desktop file?

mikkov 2008-08-14 21:04

Re: Python Statusbar applet possible?
 
as far as I know it is not possible, because python bindings are missing. But I would be happy to be wrong :)

mikkov 2008-08-18 18:23

Re: Python Statusbar applet possible?
 
I am happy to prove myself wrong. This should give you green statusbar button which opens "Hello World" dialog.

Code:

import gtk
import hildondesktop


class statusbar_applet(hildondesktop.StatusbarItem):
    def __init__(self):
        hildondesktop.StatusbarItem.__init__(self)
       
        button = gtk.Button()
        button.set_image(gtk.image_new_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_MENU))
        button.set_name("hildon-navigator-button-one")
        button.set_size_request(80,80)
        button.connect("clicked",self.button_clicked_event)
        self.add(button)
        self.show_all()
       
    def button_clicked_event(self,widget,data=None):
        mdlg = gtk.MessageDialog(None,0,gtk.MESSAGE_INFO,gtk.BUTTONS_OK,"Hello World!")
        mdlg.run()
        mdlg.destroy()
       
def hd_plugin_get_objects():
        plugin = statusbar_applet()
        return [plugin]


tz1 2008-08-19 15:54

Re: Python Statusbar applet possible?
 
THANKYOU!!!

Two other little things I had to do.

1. I named the unaltered code pystatbar.py and put it in /usr/lib/hildon-desktop/ though there is a statusbar directory, it works from desktop. I also did "chmod +x" which may or may not have been necessary. I didn't have the #!/usr/bin/python... header

2. I also needed the desktop file:

In /usr/share/applications/hildon-status-bar/ I created the file pysb.desktop:

Code:

[Desktop Entry]
Name=Python SBar
Type=python
X-Path=pystatbar

(earlier version had a typo, corrected in a later post)

I could add a category, Icon, etc, but I let it default.

But it works!!! I don't know what I missed since I tried calling it statusbar item, but if everything isn't perfect it fails without error messages and I probably had something else wrong.

THANKS!

TrueJournals 2008-08-19 19:11

Re: Python Statusbar applet possible?
 
Wow, this is pretty cool. Mikkov: Can you give a link to where you found that example code? Is there any more documentation, such as opening a menu?

[edit]Hmmm... I spoke too soon... I can't get this working at all... I enable the Python SBar item, but the Display applet shows up instead! Any ideas?

mikkov 2008-08-19 20:03

Re: Python Statusbar applet possible?
 
I wrote that code myself, partially converting from C in http://maemo.org/maemo_release_docum..._maemo_4.1.pdf

From there on it is pretty much normal python and gtk, see http://www.pygtk.org

You need to have python2.5-hildondesktop and hildon-desktop-python-loader installed before python statusbar plugins work

TrueJournals 2008-08-19 20:08

Re: Python Statusbar applet possible?
 
Alright, thanks for the links! I have both python2.5-hildondesktop and hildon-desktop-python-loader installed, but like I said, when I enable the python statusbar item I made (following tz1's instructions), I just get the Display item. If I have the display item enabled, then nothing new shows up...

Unfortunately, like tz1 said, there are NO error messages when something fails...

mikkov 2008-08-19 20:10

Re: Python Statusbar applet possible?
 
Notice: There was an error in the example code. Now it should be correct and icon has transparent background

mikkov 2008-08-19 20:23

Re: Python Statusbar applet possible?
 
Quote:

Originally Posted by TrueJournals (Post 215450)
Alright, thanks for the links! I have both python2.5-hildondesktop and hildon-desktop-python-loader installed, but like I said, when I enable the python statusbar item I made (following tz1's instructions), I just get the Display item. If I have the display item enabled, then nothing new shows up...

Unfortunately, like tz1 said, there are NO error messages when something fails...

Pretty hard to say what's wrong. It should work if you follow tz1's instructions. Maybe you should repeat the steps and double check that you copied the code unaltered. If whitespace at beginning of the lines is touched it probably won't work.

TrueJournals 2008-08-19 20:35

Re: Python Statusbar applet possible?
 
I just deleted all the files I had created, and redid all of them, following the instructions again, and still no luck. This time, the display icon doesn't even show up instead...

I suppose it's worth noting that I'm running diablo (latest update), and I have python version 2.5.2-1osso3 with python-launcher installed.


All times are GMT. The time now is 02:12.

vBulletin® Version 3.8.8