mvdm
Posts: 21
Joined: Fri Nov 25, 2016 1:34 pm

Add custom Panel Applet plugin to Panel

Fri Apr 07, 2017 7:55 pm

Hi,

Does anyone know how to create or add an existing application as a plugin to a panel on Raspbian Jessie with Pixel?

I'm not talking about a shortcut, I can do that. What I want is to have a battery indicator for my Pi-Top in between my CPU usage and Clock Panel Applets. When googling i only get articles relating to getting your taskbar back if you deleted it and creating shortcuts.

The built in battery monitor applet does not work because the pi-top hub is communicating via I2C and not ACPI. I have been unable to find ACPI drivers.

Thanks in advance

descartes
Posts: 8
Joined: Fri Dec 11, 2015 1:10 pm

Re: Add custom Panel Applet plugin to Panel

Fri Jun 02, 2017 10:21 am

I would like to know that too.

I would like to create an applet, anyone can guide where to start ?

mvdm
Posts: 21
Joined: Fri Nov 25, 2016 1:34 pm

Re: Add custom Panel Applet plugin to Panel

Sun Jul 02, 2017 6:58 pm

Hopefully not too late, I got distracted with other problems.

Here is a simple Python example.... Cant remember where I found it.

Code: Select all

import smbus
import time

bus = smbus.SMBus(1)
address = 0x0b

import gtk
 
def message(data=None):
  "Function to display messages to the user."
  
  msg=gtk.MessageDialog(None, gtk.DIALOG_MODAL,
    gtk.MESSAGE_INFO, gtk.BUTTONS_OK, data)
  msg.run()
  msg.destroy()
 
def open_app(data=None):
  message(data)
 
def close_app(data=None):
  message(data)
  gtk.main_quit()
 
def make_menu(event_button, event_time, data=None):
  menu = gtk.Menu()
  open_item = gtk.MenuItem("Open App")
  close_item = gtk.MenuItem("Close App")
  
  #Append the menu items  
  menu.append(open_item)
  menu.append(close_item)
  #add callbacks
  open_item.connect_object("activate", open_app, "Open App")
  close_item.connect_object("activate", close_app, "Close App")
  #Show the menu items
  open_item.show()
  close_item.show()
  
  #Popup the menu
  menu.popup(None, None, None, event_button, event_time)
 
def on_right_click(data, event_button, event_time):
  make_menu(event_button, event_time)
 
def on_left_click(event):
  message("Status Icon Left Clicked")
 
if __name__ == '__main__':
  icon = gtk.status_icon_new_from_stock(gtk.STOCK_ABOUT)
  icon.connect('popup-menu', on_right_click)
  icon.connect('activate', on_left_click)
  gtk.main()

Return to “Advanced users”