[Goodies-dev] [request] python plugin tutorial

Martin Forsgren mk0foma at student.chalmers.se
Mon Feb 4 23:18:33 CET 2008


Great you found a way. For my needs it isn't enough thou, but I agree it's
good with small scriptable plugins.

Den 2008-02-04 16:32:35 skrev Alexandre Leray  
<newsletters at alexandreleray.com>:

> Thanks,
>
> I'll try this. I just discovered the wonderful genmon plugin! Don't be
> rude because I'm a newbie, but I didn't know you could display images
> with it. So I solved one of my problem : displaying the battery status
> of my powerbook, as the battery plugin only support APM (hoper it's the
> right spelling) and not PMU (/proc/PMU/).
>
> Here is the little script if it could help anybody:
>
> #! /bin/sh
> charge=$(cat /proc/pmu/battery_0 | grep "^charge" | sed -e "s/[^0-9]//g")
> max_charge=$(cat /proc/pmu/battery_0 | grep "^max_charge" | sed -e
> "s/[^0-9]//g")
> charge=$(($charge*1000))
> max_charge=$(($max_charge))
> echo $(($charge/$max_charge*100/1000)) \%
>
> Then just execute this script with genmon. You can imagine displaying a
> little icon according to the battery  status.
>
> In my opinion, plugins should be like this : generic and scriptable in
> order to adapt it to user needs: scriptable GUI.
>
> What do you think about this?
>
> Bye
>
> Martin Forsgren wrote:
>> Den 2008-01-31 18:40:43 skrev Alexandre Leray
>> <newsletters at alexandreleray.com>:
>>
>>
>>> Hi,
>>>
>>> thanks for your response. I got this error :
>>> "Traceback (most recent call last):
>>>   File "test.py", line 9, in ?
>>>     plugin = xfce4.panel.Plugin()
>>> RuntimeError: could not create xfce4.panel.ExternalPanelPlugin object"
>>>
>>
>> Do you run the program as an aplet? What I now it isn't possible
>> for a program to manipulate the panel from "outside".
>>
>> Create a "program.desktop" file with content approx as below under
>> /usr/share/xfce4/panel-plugins ( path may wary but the file isn't
>> alone where it should be ).
>>
>> [Xfce Panel]
>> Encoding=UTF-8
>> Name=Network Manager
>> Comment=Easy network manager also displaying network information
>> Icon=nm-device-wireless
>> Type=Panel
>> X-XFCE-Unique=true
>> X-XFCE-Exec=/home/user/program.py
>>
>> both your program and the desktop file must be executable me think.
>>
>> Hope it works...
>> /Martin
>>
>>
>>> In the documentation the right object is called
>>> external.ExternalPanelPlugin.
>>>
>>> Any idea ?
>>>
>>> Bye
>>>
>>> Martin Forsgren wrote:
>>>
>>>> Hi,
>>>> there isn't much documentation, atleast what I've found, but
>>>> its not so hard. Check http://code.google.com/p/pynetworkmanager/ and
>>>> look
>>>> at the panel-plugin code.
>>>>
>>>> Maby this below is enough for you... (it's copy/paste code and can
>>>> contain
>>>> errors)
>>>>
>>>> ------
>>>>
>>>> # External libraries
>>>> import gtk							# use gtk-library
>>>> import xfce4.panel				# to create xfce4 panel plugin
>>>>
>>>> # Button with status icon and menu plopping up on clicking it
>>>> button = gtk.Button( "Hello World" )
>>>> button.show()
>>>>
>>>> # create an xfce panel plugin
>>>> plugin = xfce4.panel.Plugin()
>>>>
>>>> plugin.add( button )
>>>>
>>>> # Add right mouse button action
>>>> plugin.add_action_widget( button )
>>>>
>>>> # Show plugin
>>>> plugin.show()
>>>>
>>>> # Close plugin on destroy
>>>> plugin.connect("destroy", pynm.stop )
>>>>
>>>> # Ready. Start plugin
>>>> gtk.main_loop()
>>>>
>>>> ---------
>>>>
>>>> Den 2008-01-25 18:44:59 skrev Alexandre Leray
>>>> <newsletters at alexandreleray.com>:
>>>>
>>>>
>>>>
>>>>> Hi everybody,
>>>>>
>>>>> It's quite hard to find documentation on pyxfce and python plugins.
>>>>> Does
>>>>> anybody could make me a brief tutorial (like "hello world" in a  
>>>>> panel)
>>>>> or give me links for?
>>>>>
>>>>> Thanks!
>>>>> _______________________________________________
>>>>> Goodies-dev mailing list
>>>>> Goodies-dev at xfce.org
>>>>> http://foo-projects.org/mailman/listinfo/goodies-dev
>>>>>
>>>>>
>>>> _______________________________________________
>>>> Goodies-dev mailing list
>>>> Goodies-dev at xfce.org
>>>> http://foo-projects.org/mailman/listinfo/goodies-dev
>>>>
>>>>
>>> _______________________________________________
>>> Goodies-dev mailing list
>>> Goodies-dev at xfce.org
>>> http://foo-projects.org/mailman/listinfo/goodies-dev
>>>
>>
>>
>> _______________________________________________
>> Goodies-dev mailing list
>> Goodies-dev at xfce.org
>> http://foo-projects.org/mailman/listinfo/goodies-dev
>>
>
> _______________________________________________
> Goodies-dev mailing list
> Goodies-dev at xfce.org
> http://foo-projects.org/mailman/listinfo/goodies-dev





More information about the Goodies-dev mailing list