Reply
Thread Tools
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#1
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?
 
Posts: 1,208 | Thanked: 1,028 times | Joined on Oct 2007
#2
as far as I know it is not possible, because python bindings are missing. But I would be happy to be wrong
 
Posts: 1,208 | Thanked: 1,028 times | Joined on Oct 2007
#3
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]

Last edited by mikkov; 2008-08-19 at 20:09. Reason: Error in the code
 

The Following 11 Users Say Thank You to mikkov For This Useful Post:
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#4
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!

Last edited by tz1; 2008-08-20 at 11:59. Reason: Fix "j" typo
 

The Following 3 Users Say Thank You to tz1 For This Useful Post:
TrueJournals's Avatar
Posts: 480 | Thanked: 378 times | Joined on Apr 2008 @ Chicago-ish
#5
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?
__________________
Disclaimer: If a program I wrote doesn't work/breaks your tablet... It's not my fault
mcedit | Utility Calculators (WIP) | PyRDesktop
My Blog | Twitter

Last edited by TrueJournals; 2008-08-19 at 19:39.
 
Posts: 1,208 | Thanked: 1,028 times | Joined on Oct 2007
#6
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
 

The Following User Says Thank You to mikkov For This Useful Post:
TrueJournals's Avatar
Posts: 480 | Thanked: 378 times | Joined on Apr 2008 @ Chicago-ish
#7
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...
__________________
Disclaimer: If a program I wrote doesn't work/breaks your tablet... It's not my fault
mcedit | Utility Calculators (WIP) | PyRDesktop
My Blog | Twitter
 
Posts: 1,208 | Thanked: 1,028 times | Joined on Oct 2007
#8
Notice: There was an error in the example code. Now it should be correct and icon has transparent background
 
Posts: 1,208 | Thanked: 1,028 times | Joined on Oct 2007
#9
Originally Posted by TrueJournals View Post
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's Avatar
Posts: 480 | Thanked: 378 times | Joined on Apr 2008 @ Chicago-ish
#10
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.
__________________
Disclaimer: If a program I wrote doesn't work/breaks your tablet... It's not my fault
mcedit | Utility Calculators (WIP) | PyRDesktop
My Blog | Twitter
 
Reply


 
Forum Jump


All times are GMT. The time now is 11:20.