maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Task Nav Panels in Python? (https://talk.maemo.org/showthread.php?t=16460)

SpiritGeek 2008-02-11 02:45

Task Nav Panels in Python?
 
At one point in time (circa '06), it was apparently possible to write task navigator panels in Python. However, search as I may, that one file is the only reference to the practice that I can find anywhere.

1) Does anyone know if it's still possible to do this in OS 2008?

2) If so, does anyone know where to find more documentation?

Thanks! :)

SpiritGeek 2008-02-11 12:29

Re: Task Nav Panels in Python?
 
Ah, I'm guessing that the absence of these bindings also means the task navigator panels aren't going to work just yet. Maybe I'll give Khertan's unofficial package a whirl. :)

Khertan 2008-02-11 13:07

Re: Task Nav Panels in Python?
 
You could try with the unofficial packages i ve made. But i ven't tryed myself to make TaskNav :)

But HomeApplet works :)

SpiritGeek 2008-02-11 23:43

Re: Task Nav Panels in Python?
 
Well, I installed the Khertan bindings (the desktop applets work great, thanks!), but so far I'm getting no love on the task navigator panel.

This is what I tried:

/usr/share/applications/hildon-navigator/pythontest.desktop
Code:

[Desktop Entry]
Name=Python Test
Type=python
X-Path=pythontest

/usr/lib/hildon-navigator/pythontest.py
(taken from sample file above)
Code:

import gtk
import hildondesktop

class PythonTestApp(hildondesktop.TaskNavigatorItem):

        def __init__(self):

                hildondesktop.TaskNavigatorItem.__init__(self)

                image = gtk.Image()
                image.set_from_stock(gtk.STOCK_CUT, gtk.ICON_SIZE_LARGE_TOOLBAR)

                button = gtk.Button()
                button.connect("clicked", self.clicked, None)
                button.set_image(image)
                button.set_size_request(80, 80);
                button.show()

                self.add(button)

def hd_plugin_get_objects():
        plugin = PythonTestApp()
        return [plugin]

The panel shows up in the "Panels" control panel and I can activate it, but it doesn't actually display it in the task navigator (though it tries, the one I disabled goes away, but the rest of the bar just slides up over where it used to be).

I'm afraid I really have no idea what I'm doing, so I'm not sure how to proceed. Any thoughts?

SpiritGeek 2008-02-14 23:02

Re: Task Nav Panels in Python?
 
Yay! With the new official desktop bindings, I have written my first task navigator panel in Python. It's just a simple shortcut to launch X Terminal.

/usr/share/applications/hildon-navigator/xterm-launch.desktop
Code:

[Desktop Entry]
Name=X Terminal Launcher
Type=python
X-Path=xterm-launch
Icon=terminal

/usr/lib/hildon-desktop/xterm-launch.py
Code:

import gtk
import hildondesktop
import os

class XTermLaunch(hildondesktop.TaskNavigatorItem):

        def clicked(self, widget, Data = None):
                os.spawnlp(os.P_NOWAIT, "maemo-invoker", "maemo-invoker", "osso-xterm.launch")

        def __init__(self):

                hildondesktop.TaskNavigatorItem.__init__(self)

                image = gtk.image_new_from_file("/usr/share/icons/hicolor/64x64/apps/terminal.png")

                button = gtk.Button()
                button.set_image(image)
                button.connect("clicked", self.clicked, None)
                button.show()

                self.add(button)


def hd_plugin_get_objects():
        plugin = XTermLaunch()
        return [plugin]

Make sure you have the required libraries installed:
hildon-desktop-python-loader_0.0.2-1_armel.deb
python2.5-hildondesktop_0.0.2-1_armel.deb
(For some reason those wouldn't install for me just by clicking. I had to download them locally and install with dpgk -i.)

I love my N810. :)

Benson 2008-02-15 15:35

Re: Task Nav Panels in Python?
 
Sweet! A single launcher is certainly more useful (to me) than the non-editable contacts button. Perhaps I should learn enough Python to make a second menu... Thanks for showing the way!

jgallen23 2008-02-15 22:16

Re: Task Nav Panels in Python?
 
SpiritGeek - do you have an example of making a multi application menu (like the default one)? I'd love to have a menu with just my test apps.

SpiritGeek 2008-02-16 13:42

Re: Task Nav Panels in Python?
 
Quote:

Originally Posted by Benson (Post 142836)
Sweet! A single launcher is certainly more useful (to me) than the non-editable contacts button. Perhaps I should learn enough Python to make a second menu... Thanks for showing the way!

You're quite welcome, I'm glad you found it useful!

I've only just started taking up Python myself. I've done mostly VB/VBScript, PHP, and JavaScript, and coming from that background it's been very easy to learn. There are a couple of quirks (mostly the indentation and data types), but after I acclimated to those it has rapidly become my very favorite language. I highly recommend it for fast, easy, cross-platform development.

Happy coding!

SpiritGeek 2008-02-16 13:47

Re: Task Nav Panels in Python?
 
Quote:

Originally Posted by jgallen23 (Post 142986)
SpiritGeek - do you have an example of making a multi application menu (like the default one)? I'd love to have a menu with just my test apps.

Unfortunately I don't, but it should be fairly straight-forward. The task navigator panels are just GTK widgets, so I imagine you would just need to create additional widgets representing your menu (perhaps a treeview?) off to the side when it's clicked. However, I'm brand-new both to Python and GTK programming in general, so I couldn't give you any examples just yet.

Good luck!

Khertan 2008-02-16 17:13

Re: Task Nav Panels in Python?
 
Hum ... you give me a idea ... a script menu :)


All times are GMT. The time now is 14:27.

vBulletin® Version 3.8.8