def main(): from optparse import OptionParser parser = OptionParser() parser.add_option("-w", "--windowed", dest="windowed", default=False, action="store_true", help="run windowed") parser.add_option( "--loglevel", dest="loglevel", default="ERROR", help="set logging level to LOGLEVEL", metavar="LOGLEVEL" ) parser.add_option("--oaf-activate-iid", dest="iid", default=None) parser.add_option("--oaf-ior-fd", dest="fd", default=None) opts, _args = parser.parse_args() levels = { "DEBUG": logging.DEBUG, "INFO": logging.INFO, "WARNING": logging.WARNING, "ERROR": logging.ERROR, "CRITICAL": logging.CRITICAL, } LOGGER.setLevel(levels.get(opts.loglevel, logging.NOTSET)) if opts.windowed: LOGGER.info("Starting jukebox applet windowed") run_in_window() else: LOGGER.info("Starting jukebox applet via Bonobo") gnomeapplet.bonobo_factory( "OAFIID:JukeboxApplet_Factory", gnomeapplet.Applet.__gtype__, "Jukebox Applet", "0.1", jukebox_applet_factory, )
def run_in_panel(): """Run applet in panel""" gnomeapplet.bonobo_factory( "OAFIID:GNOME_ProxySwitcher_Factory", ProxySwitcherGnomeApplet.__gtype__, "Proxy switcher applet", "0", proxy_applet_factory, )
def activate_factory(window_mode=False): """ Module used to activate the bonobo factory """ #log.logger.info(" ##########################################") #log.logger.info(" : Starting Factory") #log.logger.info(" ##########################################") gnomeapplet.bonobo_factory("OAFIID:GNOME_ghellanzb_applet_Factory", gnomeapplet.Applet.__gtype__, name, version, applet_factory, window_mode)
def main(debug): global DEBUG DEBUG = debug # Create the applet gnomeapplet.bonobo_factory("OAFIID:GNOME_ComputertempApplet_Factory", computertempApplet.__gtype__, glob.name, glob.version, computertemp_applet_factory)
def bonobo_factory (): return gnomeapplet.bonobo_factory ( "OAFIID:Freespeak_Applet_Factory", gnomeapplet.Applet.__gtype__, defs.PACKAGE, defs.VERSION, applet_factory)
def main(): if len(sys.argv) > 1: print "given args: " + " ".join(sys.argv) app = AppletController( None ) app.on_preference_request( None, None ) on_delete = lambda widget, data=None : (gtk.main_quit(),False)[-1] window = app.fm.window window.connect('destroy_event', on_delete ) window.connect('delete_event', on_delete ) window.show_all() gtk.main() else: gnomeapplet.bonobo_factory( IID_FACTORY ,gnomeapplet.Applet.__gtype__,"hello", "0", applet_factory )
def main(): if len(sys.argv) == 2: if sys.argv[1] == "run-in-window": mainWindow = gtk.Window(gtk.WINDOW_TOPLEVEL) mainWindow.set_title("Ubuntu System Panel") mainWindow.connect("destroy", gtk.main_quit) applet = gnomeapplet.Applet() lockIndicator_factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory('OAFIID:LockIndicatorApplet_Factory', gnomeapplet.Applet.__gtype__, 'Lock Indicator Applet', '0.1', lockIndicator_factory)
def main(args): """Main function""" gobject.type_register(IR_Switcher_Applet) # debug mode should open a window instead of the applet itself if len(sys.argv) > 1 and sys.argv[1] == '--window': mainWindow = gtk.Window() mainWindow.set_title('Applet window') mainWindow.connect('destroy', gtk.main_quit) applet = gnomeapplet.Applet() applet_factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory("OAFIID:IR_Switcher_Factory", IR_Switcher_Applet.__gtype__, "hello", "0", applet_factory)
def main(): """Entrypoint for the panel applet.""" gtk.gdk.threads_init() if len(sys.argv) == 2 and sys.argv[1] == "run-in-window": print "here" main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title(_("Webilder Applet Window")) main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() WebilderApplet(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory("OAFIID:GNOME_WebilderApplet_Factory", gnomeapplet.Applet.__gtype__, "webilder-hello", "0", webilder_applet_factory)
def start(self, option, logging): self.option = option self.logging = logging try: import gnomeapplet except: print "not installed Python bindings for GNOME Panel applets." print "ex) sudo yum install gnome-python2-applet" self.logging.error( 'not installed Python bindings for GNOME Panel applets.') self.logging.error('ex) sudo yum install gnome-python2-applet') sys.exit(2) if option.getWindow(): self.logging.debug('Running ... window mode.') import pygtk pygtk.require("2.0") main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Wallpaperoptimizer Applet Window") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() self._factory(app, None) app.reparent(main_window) main_window.show_all() wh = main_window.get_size() main_window.resize(wh[0] * 2, wh[1]) gtk.main() elif (option.getIID() is None and option.getFD() is None): self._runConsoleSide(self.option, self.logging) else: self.logging.debug('Running ... applet mode.') import pygtk pygtk.require("2.0") gnomeapplet.bonobo_factory( "OAFIID:wallpaperoptimizerApplet_Factory", gnomeapplet.Applet.__gtype__, "wallpaper changer", "1.0", self._factory)
if (self._name_change_handler_id): self.workspace.disconnect(self._name_change_handler_id) self.workspace = really_get_active_workspace(self.screen) self._name_change_handler_id = self.workspace.connect( "name-changed", self._on_workspace_name_changed) self.show_workspace_name() def _on_workspace_name_changed(self, event): self.show_workspace_name() def show_workspace_name(self): self.label.set_text(self.workspace.get_name()) self.show_all() def really_get_active_workspace(screen): # This bit is needed because wnck is asynchronous. while gtk.events_pending(): gtk.main_iteration() return screen.get_active_workspace() def wsn_factory_init(applet, iid): return applet.init() gobject.type_register(WSNameApplet) gnomeapplet.bonobo_factory("OAFIID:GNOME_WorkspaceName_Factory", WSNameApplet.__gtype__, "workspace name", "0", wsn_factory_init)
level = logging.DEBUG, format = LOG_FORMAT) logging.log(logging.DEBUG, "running in window") main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Cricket Score Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() sample_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() arg = sys.argv[1] if arg.startswith ("--oaf-activate-iid=") or arg.startswith ("--oaf-ior-fd="): #Setup Log files dirname = gnome_cricscore_globals.logdir logfile = file (os.path.join (dirname, "cricscore.log"), "w") sys.stdout = logfile sys.stderr = logfile logging.basicConfig (stream = logfile, level = logging.DEBUG, format = LOG_FORMAT) gnomeapplet.bonobo_factory("OAFIID:GNOME_CricketScoreApplet_Factory", gnomeapplet.Applet.__gtype__, "cricscore", "0", sample_factory)
## eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#2E2E2E")) eb.add(hbox) self.window.add(eb) eb.show_all() ##self.window.add(self.dockbar.container) def delete_event (self,widget,event,data=None): return False def destroy (self,widget,data=None): gtk.main_quit() def main(self): gtk.main() def dockbar_factory(applet, iid): dockbar = dockbarx.dockbar.DockBar(applet) applet.set_background_widget(applet) applet.show_all() return True ##gc.enable() if len(sys.argv) == 2 and sys.argv[1] == "run-in-window": dockbarwin = DockBarWindow() dockbarwin.main() else: gnomeapplet.bonobo_factory("OAFIID:GNOME_DockBarXApplet_Factory", gnomeapplet.Applet.__gtype__, "dockbar applet", "0", dockbar_factory)
</submenu> </popup>""" verbs = [('Astronomy', run_apod),('Wikipedia', run_wpod),('Earth', run_epod)] applet.setup_menu(xml, verbs, None) def run_apod(*arguments): os.system('/usr/lib/potd/potd.sh apod > ~/potd.log 2>&1') def run_wpod(*arguments): os.system('/usr/lib/potd/potd.sh wpod > ~/potd.log 2>&1') def run_epod(*arguments): os.system('/usr/lib/potd/potd.sh epod > ~/potd.log 2>&1') def applet_factory(applet, iid): print 'Starting POTD instance:', applet, iid label = gtk.Label("Pic Of The Day") create_menu(applet) applet.add(label) applet.show_all() return True if __name__ == '__main__': # testing for execution if len(sys.argv) > 1 and sys.argv[1] == '-d': # debugging mainWindow = gtk.Window() mainWindow.set_title('Applet window') mainWindow.connect('destroy', gtk.main_quit) applet = gnomeapplet.Applet() applet_factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory("OAFIID:GNOME_POTDApplet_Factory",gnomeapplet.Applet.__gtype__,"Picture of the Day", "0.2", applet_factory)
self.event_box.connect("button_press_event", self.show_menu) self.applet.add(self.event_box) self.applet.set_background_widget(applet) self.applet.show_all() self.mosq = mosquitto.Mosquitto() self.mosq.on_message = self.on_message self.mosq.connect("localhost") self.mosq.loop_start() self.mosq.subscribe("sensors/cc128/ch1", 0) self.applet.connect('change-background', self.on_change_background) def CurrentCostMQTT_factory(applet, iid): CurrentCostMQTT(applet, iid) return gtk.TRUE if len(sys.argv) == 2: if sys.argv[1] == "-d": #Debug mode main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() CurrentCostMQTT_factory(app,None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() if __name__ == '__main__': gnomeapplet.bonobo_factory("OAFIID:CurrentCostMQTT_Factory", gnomeapplet.Applet.__gtype__, "MQTT", "0", CurrentCostMQTT_factory)
def _on_workspace_changed(self, event, old_workspace): if self.toggle.get_active(): self.toggle.set_active(False) if (self._name_change_handler_id): self.workspace.disconnect(self._name_change_handler_id) self.workspace = really_get_active_workspace(self.screen) self._name_change_handler_id = self.workspace.connect("name-changed", self._on_workspace_name_changed) self.show_workspace_name() def _on_workspace_name_changed(self, event): self.show_workspace_name() def show_workspace_name(self): self.label.set_text(self.workspace.get_name()) self.show_all() def really_get_active_workspace(screen): # This bit is needed because wnck is asynchronous. while gtk.events_pending(): gtk.main_iteration() return screen.get_active_workspace() def wsn_factory_init(applet, iid): return applet.init() gobject.type_register(WSNameApplet) gnomeapplet.bonobo_factory("OAFIID:GNOME_WorkspaceName_Factory", WSNameApplet.__gtype__, "workspace name", "0", wsn_factory_init)
self.w.unmap() def factory(applet, iid): MyApplet(applet) applet.show_all() return True from twisted.internet import reactor # instead of reactor.run(), we do the following: reactor.startRunning() reactor.simulate() gnomeapplet.bonobo_factory("OAFIID:GNOME_Buildbot_Factory", gnomeapplet.Applet.__gtype__, "buildbot", "0", factory) # code ends here: bonobo_factory runs gtk.mainloop() internally and # doesn't return until the program ends # SUPPORTING FILES: # save the following as ~/lib/bonobo/servers/bb_applet.server, and update all # the pathnames to match your system bb_applet_server = """ <oaf_info> <oaf_server iid="OAFIID:GNOME_Buildbot_Factory" type="exe" location="/home/warner/stuff/buildbot-trunk/contrib/bb_applet.py">
# Redirect to a file in /tmp (debug only) This solves the difficulty # in seeing stdout while in tray mode. if 1: pylog = open("/tmp/pyala_tray", "w") pylog.write("Started pyala tray starter.\n") sys.stdout = pylog; sys.stderr = pylog # Set these for tray print "Channelled stdout" print sys.argv print os.environ['PATH'] print os.environ['HOME'] print "uid", os.getuid(), "guid", os.getgid() print "euid", os.geteuid(), "eguid", os.geteuid() syslog.openlog("PyAla tray") try: gnomeapplet.bonobo_factory("OAFIID:GNOME_PYAlaApplet_Factory", gnomeapplet.Applet.__gtype__,"", "0", PYAla_applet_factory) except: print sys.exc_info() syslog.syslog("Ended with exception. %s", sys.exc_info()[1]) sys.exit(1)
def bonobo_factory(): return gnomeapplet.bonobo_factory("OAFIID:Freespeak_Applet_Factory", gnomeapplet.Applet.__gtype__, defs.PACKAGE, defs.VERSION, applet_factory)
self.applet.setup_menu(self.propxml, self.verbs, None) def menu_factory(applet, iid): MenuWin(applet, iid) applet.show() return True def quit_all(widget): gtk.main_quit() sys.exit(0) if len(sys.argv) == 2 and sys.argv[1] == "run-in-window": gtk.gdk.threads_init() main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title(NAME) main_window.connect("destroy", quit_all) app = gnomeapplet.Applet() menu_factory(app, None) app.reparent(main_window) main_window.show() gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave() else: gnomeapplet.bonobo_factory("OAFIID:GNOME_mintMenu_Factory", gnomeapplet.Applet.__gtype__, "mintMenu", "0", menu_factory)
#applet.set_background_widget(applet) #applet.connect('button-press-event',button_press) applet.add(ebox) applet.show_all() print applet.window return gtk.TRUE if __name__ == '__main__': papplet = PanelApplet() if len(sys.argv) == 2: if sys.argv[1] == "run-in-window": mainWindow = gtk.Window(gtk.WINDOW_TOPLEVEL) mainWindow.set_title("Toggl applet") mainWindow.connect("destroy", gtk.main_quit) # gnome bonobo applet stuff applet = gnomeapplet.Applet() papplet.factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: #print "Starting gnomeapplet bonobo" gnomeapplet.bonobo_factory("OAFIID:GNOME_TogglApplet_Factory", gnomeapplet.Applet.__gtype__, "toggl", "0", papplet.factory)
if self.main_loaded == False: self.show_main_window() self.main_window.widget.hide() self.main_window.on_add_scheduled_task_menu_activate() def show_help(self, *args): if self.main_loaded == False: self.show_main_window() self.main_window.widget.hide() self.main_window.on_manual_menu_activate() def show_about(self, *args): if self.main_loaded == False: self.show_main_window() self.main_window.widget.hide() self.main_window.on_about_menu_activate() gobject.type_register(ScheduleApplet) #factory def schedule_applet_factory(applet, iid): ScheduleApplet(applet, iid, debug_flag, manual_poscorrect) return True gnomeapplet.bonobo_factory("OAFIID:GNOME_GnomeSchedule_Factory", ScheduleApplet.__gtype__, "GnomeScheduleApplet", "0", schedule_applet_factory)
print "Building" svnApplet(applet, iid) return gtk.TRUE #------------------------------------------------------------------------------- # Main #------------------------------------------------------------------------------- if len(sys.argv) == 2 and sys.argv[1] == "debug": # Here, it is debug. main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Subversion Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() svnAppletFactory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() else: # Normal functionnality. gnomeapplet.bonobo_factory("OAFIID:GNOME_SvnApplet_Factory", svnApplet.__gtype__, pglobals.name, pglobals.version, svnAppletFactory)
self.tbutton.connect("toggled",self.cal_show) if self.show_time: self.set_time() self.tooltips.set_tip(self.tbutton,convert_to_str(self.day)+" "+mon_name[self.month-1]+" "+convert_to_str(self.year)) self.applet.setup_menu(self.propxml,self.verbs,None) self.applet.add(self.tbutton) self.applet.show_all() self.applet.set_background_widget(self.applet) gobject.timeout_add(self.timeout_interval,self.timeout_callback, self) gobject.timeout_add(6000,self.print_day, self) def jcalendar_applet_factory(applet, iid): Jcalendar(applet,iid) return gtk.TRUE if len(sys.argv) == 2 and sys.argv[1] == "run-in-window": main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Japplet Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() jcalendar_applet_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() if __name__ == '__main__': gnomeapplet.bonobo_factory("OAFIID:GNOME_PyJcalendarApplet_Factory", gnomeapplet.Applet.__gtype__, "Jcalendar", "0", jcalendar_applet_factory)
main_window.set_title("HSENCFC Applet") main_window.connect("destroy", gtk.main_quit) main_window.connect("key-press-event", key_press_event) app = gnomeapplet.Applet() HS_applet_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() syslog.syslog("Ended window") sys.exit() # ------------------------------------------------------------------------ if __name__ == '__main__': syslog.openlog("HSENCFS Tray") syslog.syslog("Starting embedded") try: gnomeapplet.bonobo_factory("OAFIID:GNOME_HSENCApplet_Factory", gnomeapplet.Applet.__gtype__, "", "0", HS_applet_factory) except: print sys.exc_info() syslog.syslog("Ended with exception. %s", sys.exc_info()[1]) sys.exit(1) syslog.syslog("Ended Normally.") sys.exit(0)
def background_show(applet): print "background: ", applet.get_background() def applet_factory(applet, iid): print "Creating new applet instance" #label = gtk.Label("Success!") #applet.add(label) app = Stopwatch(applet, iid) applet.show_all() return True if len(sys.argv) == 2 and sys.argv[1] == "run-in-window": main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet Stopwatch") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() applet_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() print "Starting factory" gnomeapplet.bonobo_factory("OAFIID:GNOME_PythonAppletStopwatch_Factory", gnomeapplet.Applet.__gtype__, "hello", "0", applet_factory) print "Factory ended"
#!/usr/bin/python import sys import gtk import pygtk pygtk.require('2.0') import gnomeapplet from commotion_applet_support import applet_factory if __name__ == '__main__': # testing for execution print('Starting factory') if len(sys.argv) > 1 and sys.argv[1] == '-d': # debugging mainWindow = gtk.Window() mainWindow.set_title('Applet window') mainWindow.connect('destroy', gtk.main_quit) applet = gnomeapplet.Applet() applet_factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory('OAFIID:commotion-mesh-applet_Factory', gnomeapplet.Applet.__gtype__, 'commotion-mesh-applet', '0.0', applet_factory)
applet.add(ebox) applet.show_all() print applet.window return gtk.TRUE if __name__ == '__main__': papplet = PanelApplet() if len(sys.argv) == 2: if sys.argv[1] == "run-in-window": mainWindow = gtk.Window(gtk.WINDOW_TOPLEVEL) mainWindow.set_title("Toggl applet") mainWindow.connect("destroy", gtk.main_quit) # gnome bonobo applet stuff applet = gnomeapplet.Applet() papplet.factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: #print "Starting gnomeapplet bonobo" gnomeapplet.bonobo_factory("OAFIID:GNOME_TogglApplet_Factory", gnomeapplet.Applet.__gtype__, "toggl", "0", papplet.factory)
</popup>""" verbs = [("About", self.showAboutDialog)] applet.setup_menu(propxml, verbs, None) def showAboutDialog(*arguments, **keywords): pass def ActivitiesFactory(applet, iid): ActivitiesApplet(applet, iid) return gtk.TRUE if __name__ == '__main__': gobject.type_register(ActivitiesApplet) if len(sys.argv) == 2: if sys.argv[1] == "run-in-window": mainWindow = gtk.Window(gtk.WINDOW_TOPLEVEL) mainWindow.set_title("Ubuntu System Panel") mainWindow.connect("destroy", gtk.main_quit) applet = gnomeapplet.Applet() ActivitiesApplet(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory("OAFIID:GNOME_Activities_Factory", gnomeapplet.Applet.__gtype__, "Activities", "1.0", ActivitiesFactory)
status = JenkinsStatus(applet, iid) #hbox = gtk.HBox() #hbox.add(status.button) # hbox.add(status.area) #hbox.add( #applet.add(hbox) applet.show_all() return True if len(sys.argv) == 2: if sys.argv[1] == "run-in-window": mainWindow = gtk.Window(gtk.WINDOW_TOPLEVEL) mainWindow.set_title("Ubuntu System Panel") mainWindow.connect("destroy", gtk.main_quit) applet = gnomeapplet.Applet() factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() if __name__ == '__main__': print "Starting factory" gnomeapplet.bonobo_factory("OAFIID:My_Factory", gnomeapplet.Applet.__gtype__, "My_New_Applet", "1.0", factory)
def hide(self, widget, event): #print "Let's hide this window" widget.hide() return def create_factory(applet, iid): ghellanzb_applet(applet, iid) return True if len(sys.argv) == 2 and sys.argv[1] == "--window": #print 'ok we do something' #DEBUG window = gtk.Window() window.set_title('hellanzb applet') window.connect('destroy', gtk.main_quit) app = gnomeapplet.Applet() create_factory(app, None) app.reparent(window) window.show_all() gtk.main() sys.exit() logger.info("Starting factory") gnomeapplet.bonobo_factory("OAFIID:GNOME_ghellanzb_applet_Factory", gnomeapplet.Applet.__gtype__, "ghellanzb", version, create_factory) logger.info("Factory ended")
self.ha.get_next_pass() signal.alarm(0) signal.signal(signal.SIGALRM, self.pass_begin_alarm) signal.alarm(self.ha.seconds_to_next_pass) def showAboutDialog(self, widget, menuname): #print menuname pass def class_factory(applet, iid): PyApplet(applet) return True if len(sys.argv) == 2 and sys.argv[1] == "-debug": print "running in window" main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() class_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() gnomeapplet.bonobo_factory("OAFIID:ISS_Gnome_Panel_Factory", gnomeapplet.Applet.__gtype__, "hello", "0", class_factory)
gobject.timeout_add(self.timeout_interval, self.displayNextWord) #Register the applet datatype gobject.type_register(HindiScroller) def hindi_scroller_factory(applet, iid): HindiScroller(applet, iid) return gtk.TRUE #Very useful if I want to debug. To run in debug mode python hindiScroller.py -d if len(sys.argv) == 2: if sys.argv[1] == "-d": #Debug mode main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() hindi_scroller_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() #If called via gnome panel, run it in the proper way if __name__ == '__main__': gnomeapplet.bonobo_factory("OAFIID:GNOME_HindiScroller_Factory", HindiScroller.__gtype__, "hello", "0", hindi_scroller_factory)
def run_in_panel(): gnomeapplet.bonobo_factory("OAFIID:GNOME_ForismaticNotify_Factory", GnomeForismaticApplet.__gtype__, "Applet Forismatic Notify", "0", applet_factory)
def update_pass_data(self, widget, menuname): self.ha.get_next_pass() signal.alarm(0) signal.signal(signal.SIGALRM, self.pass_begin_alarm) signal.alarm(self.ha.seconds_to_next_pass) def showAboutDialog(self, widget, menuname): # print menuname pass def class_factory(applet, iid): PyApplet(applet) return True if len(sys.argv) == 2 and sys.argv[1] == "-debug": print "running in window" main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() class_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() gnomeapplet.bonobo_factory("OAFIID:ISS_Gnome_Panel_Factory", gnomeapplet.Applet.__gtype__, "hello", "0", class_factory)
pygtk.require('2.0') gtk.gdk.threads_init() def applet_factory(applet, iid): traffic_applet.TrafficApplet(applet, iid) return True if __name__ == '__main__': if len(sys.argv) == 2: if sys.argv[1] == '--run-in-window': window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title('Traffic Monitor') window.connect('destroy', gtk.main_quit) applet = gnomeapplet.Applet() applet_factory(applet, None) applet.reparent(window) window.show_all() gtk.main() sys.exit() elif sys.argv[1] == '--help': print ''' --run-in-window - run the applet in a window --help - show this message''' else: gnomeapplet.bonobo_factory('OAFIID:GNOME_TrafficApplet_Factory', traffic_applet.TrafficApplet.__gtype__, 'Traffic Applet', '0.9', applet_factory)
def refresh_seconds(self): self.label.set_text(self.format_seconds(self.get_remaining_seconds())) return gtk.TRUE gobject.type_register(DeathClock) def sample_factory(applet, iid): DeathClock(applet, iid) return gtk.TRUE if len(sys.argv) == 2 and sys.argv[1] == "run-in-window": print "Running in debug mode" main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet") main_window.connect("destroy", gtk.mainquit) app = gnomeapplet.Applet() sample_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() else: if __name__ == '__main__': gnomeapplet.bonobo_factory("OAFIID:GNOME_DeathClock_Factory", gnomeapplet.Applet.__gtype__, "hello", "0", sample_factory)
self.label.set_markup(wordToShow) self.applet.add(self.label) self.applet.show_all() gobject.timeout_add(self.timeout_interval, self.displayNextWord) #Register the applet datatype gobject.type_register(HindiScroller) def hindi_scroller_factory(applet,iid): HindiScroller(applet,iid) return gtk.TRUE #Very useful if I want to debug. To run in debug mode python hindiScroller.py -d if len(sys.argv) == 2: if sys.argv[1] == "-d": #Debug mode main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() hindi_scroller_factory(app,None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() #If called via gnome panel, run it in the proper way if __name__ == '__main__': gnomeapplet.bonobo_factory("OAFIID:GNOME_HindiScroller_Factory", HindiScroller.__gtype__, "hello", "0", hindi_scroller_factory)
import gnomeapplet import sys import applet.ui as ui import gtk def Factory(applet, iid): myApplet = ui.myApplet(applet) myApplet.run() return gtk.TRUE if len(sys.argv) == 2: if sys.argv[1] == "test": #Debug mode main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() Factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() #If called via gnome panel, run it in the proper way if __name__ == '__main__': gnomeapplet.bonobo_factory("OAFIID:GNOME_SimpleRemoteControl_Factory", gnomeapplet.Applet.__gtype__, "hello", "0", Factory)
def factory(applet, iid): jsa = JadwalSholatApplet(applet) applet.show_all() return True if len(sys.argv) == 2: if sys.argv[1] == "--window": window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("Jadwal Sholat") window.connect("destroy", gtk.main_quit) applet = gnomeapplet.Applet() factory(applet, None) applet.reparent(window) window.show_all() gtk.main() sys.exit() gnomeapplet.bonobo_factory("OAFIID:GNOME_JadwalSholat_Factory", gnomeapplet.Applet.__gtype__, "Penunjuk waktu sholat", "1.0", factory)
self.cont.add(self.label) self.cont.add(self.hbut) self.applet.add(self.cont) self.applet.show_all() #gobject.timeout_add(self.timeout_interval, self.displayNextWord) #Register the applet datatype gobject.type_register(KeyboardLayoutShifter) def KeyboardLayoutShifter_factory(applet,iid): KeyboardLayoutShifter(applet,iid) return gtk.TRUE #Very useful if I want to debug. To run in debug mode python hindiScroller.py -d if len(sys.argv) == 2: if sys.argv[1] == "-d": #Debug mode main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Python Applet") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() KeyboardLayoutShifter_factory(app,None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() #If called via gnome panel, run it in the proper way if __name__ == '__main__': gnomeapplet.bonobo_factory("OAFIID:GNOME_KeyboardLayoutShifter_Factory", KeyboardLayoutShifter.__gtype__, "hello", "0", KeyboardLayoutShifter_factory)
#!/usr/bin/env python import pygtk pygtk.require('2.0') import gtk import gnomeapplet import subprocess def lyriczilla_applet_factory(applet, iid): socket = gtk.Socket() applet.add(socket) subprocess.Popen(['lyriczilla-nest', str(socket.get_id())]) socket.set_size_request(400, 20) applet.show_all() return gtk.TRUE gnomeapplet.bonobo_factory( 'OAFIID:LyricZilla_Applet_Factory', gnomeapplet.Applet.__gtype__, "LyricZillaApplet", "0", lyriczilla_applet_factory)
app = gtk.Window(gtk.WINDOW_TOPLEVEL) app.set_title(_(u"Time Tracker")) applet = gnomeapplet.Applet() applet_factory(applet, None) applet.reparent(app) app.show_all() gtk.main() elif start_window: if start_window == "stats": from stats import StatsViewer stats_viewer = StatsViewer().show() elif start_window == "edit": from edit_activity import CustomFactController CustomFactController().show() elif start_window == "prefs": from preferences import PreferencesEditor PreferencesEditor().show() gtk.main() else: gnomeapplet.bonobo_factory( "OAFIID:Hamster_Applet_Factory", gnomeapplet.Applet.__gtype__, defs.PACKAGE, defs.VERSION, applet_factory)
######################## def internode_factory(applet, iid): """ Creates an Internode Usage Meter Applet """ InternodeMeter(applet, iid) return True if len(sys.argv) == 2 and sys.argv[1] == "--window": # Launch the applet in its own window main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title("Internode") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() internode_factory(app, None) app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() else: # Launch the applet through the bonobo interfaces (as a panel applet) gnomeapplet.bonobo_factory("OAFIID:InternodeUsageMeterApplet_Factory", gnomeapplet.Applet.__gtype__, "internode", "0", internode_factory)
#!/usr/bin/env python import sys import gtk import pygtk pygtk.require('2.0') import gnomeapplet from TailsClockApplet import applet_factory if __name__ == '__main__': # testing for execution if len(sys.argv) > 1 and sys.argv[1] == '-d': # debugging mainWindow = gtk.Window() mainWindow.set_title('Tails Clock Window') mainWindow.connect('destroy', gtk.main_quit) applet = gnomeapplet.Applet() applet_factory(applet, None, None, True) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory('OAFIID:TailsClock_Factory', gnomeapplet.Applet.__gtype__, 'TailsClock', '0.1', applet_factory)
args = sys.argv[1:] for o, a in opts: if o in ("-h", "--help"): usage() elif o in ("-w", "--window"): standalone = True print 'Running with options:', { 'standalone': standalone, } gnome.program_init('glipper', '1.0', properties={gnome.PARAM_APP_DATADIR: glipper.DATA_DIR}) set_process_name() if standalone: import gnome gnome.init(glipper.defs.PACKAGE, glipper.defs.VERSION) set_process_name() build_window() gtk.main() else: gnomeapplet.bonobo_factory("OAFIID:Glipper_Factory", gnomeapplet.Applet.__gtype__, glipper.defs.PACKAGE, glipper.defs.VERSION, applet_factory)
# # author: Jonathan Zacsh <*****@*****.**> # # Present our user with a gnome-applet, exactly like the volume-slider in # GNOME, that allows them to change the speed of our espeak TTS utility in # ~/bin/share/tts_xsel #@TODO: finish reading: # http://saravananthirumuruganathan.wordpress.com/2010/01/15/creating-gnome-panel-applets-in-python/ #@TODO: finish reading: # http://www.znasibov.info/blog/post/gnome-applet-with-python-part-1.html import pygtk pygtk.require('2.0') import gtk import gnomeapplet def sample_factory(applet, iid): label = gtk.Label("Success!") applet.add(label) applet.show_all() return gtk.TRUE gnomeapplet.bonobo_factory("OAFIID:TTSKeyVolumeSlider", gnomeapplet.Applet.__gtype__, "hello world", "0", sample_factory)
#!/usr/bin/python import sys import gtk import pygtk pygtk.require('2.0') import gnomeapplet from ${name}Applet import applet_factory if __name__ == '__main__': # testing for execution print('Starting factory') if len(sys.argv) > 1 and sys.argv[1] == '-d': # debugging mainWindow = gtk.Window() mainWindow.set_title('Applet window') mainWindow.connect('destroy', gtk.main_quit) applet = gnomeapplet.Applet() applet_factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory('OAFIID:${name}_Factory', gnomeapplet.Applet.__gtype__, '${name}', '0.1', applet_factory)
def create_menu(self): self.applet.setup_menu(self.propxml, self.verbs, None) def menu_factory( applet, iid ): MenuWin( applet, iid ) applet.show() return True def quit_all(widget): gtk.main_quit() sys.exit(0) if len(sys.argv) == 2 and sys.argv[1] == "run-in-window": gtk.gdk.threads_init() main_window = gtk.Window( gtk.WINDOW_TOPLEVEL ) main_window.set_title( NAME ) main_window.connect( "destroy", quit_all ) app = gnomeapplet.Applet() menu_factory( app, None ) app.reparent( main_window ) main_window.show() gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave() else: gnomeapplet.bonobo_factory("OAFIID:GNOME_mintMenu_Factory", gnomeapplet.Applet.__gtype__, "mintMenu", "0", menu_factory)
sys.exit(0) ## FIXME #def restart(self): # self.quit() def starcalAppletFactory(applet, iid): scal = StarCalApplet(applet, iid) return True if len(sys.argv) > 1 and sys.argv[1] in ('-w', '--window'): main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title(core.APP_DESC + ' Gnome Applet') main_window.connect('destroy', gtk.main_quit) app = gnomeapplet.Applet() starcalAppletFactory(app, None) app.reparent(main_window) main_window.show_all() sys.exit(gtk.main()) if __name__ == '__main__': gnomeapplet.bonobo_factory( 'OAFIID:GNOME_Starcal2Applet_Factory', gnomeapplet.Applet.__gtype__, core.APP_DESC, '0', starcalAppletFactory, )
applet.add(label) applet.show_all() gobject.timeout_add(5000,updateSensors,applet) updateSensors(applet) return True def updateSensors(applet): sensorReadings = recvReading.recvReading() output = "" for name, val in sensorReadings.iteritems(): if val[0] == 'Temp': output += name + ': <b>'+ val[1]+ " °C </b>" applet.get_child().set_label(output) return True if __name__ == '__main__': # testing for execution if len(sys.argv) > 1 and sys.argv[1] == '-d': # debugging mainWindow = gtk.Window() mainWindow.set_title('Applet window') mainWindow.connect('destroy', gtk.main_quit) applet = gnomeapplet.Applet() applet_factory(applet, None) applet.reparent(mainWindow) mainWindow.show_all() gtk.main() sys.exit() else: gnomeapplet.bonobo_factory('OAFIID:SensorApplet_Factory', gnomeapplet.Applet.__gtype__, 'Sensor applet', '0.5', applet_factory)
self.check_chain_username.set_tooltip_text(_('When the password is copied to clipboard, put the username before the password as a clipboard "chain"')) self.section_misc.append_widget(None, self.check_chain_username) def run(self): "Runs the dialog" self.show_all() def factory(applet, iid): "Applet factory function" RevelationApplet(applet, iid) return True if __name__ == "__main__": gnome.init(config.APPNAME, config.VERSION) gnomeapplet.bonobo_factory( "OAFIID:GNOME_RevelationApplet_Factory", gnomeapplet.Applet.__gtype__, config.APPNAME, config.VERSION, factory )
sys.exit(0) ## FIXME #def restart(self): # self.quit() def starcalAppletFactory(applet, iid): scal = StarCalApplet(applet, iid) return True if len(sys.argv)>1 and sys.argv[1] in ('-w', '--window'): main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_title(core.APP_DESC+' Gnome Applet') main_window.connect('destroy', gtk.main_quit) app = gnomeapplet.Applet() starcalAppletFactory(app, None) app.reparent(main_window) main_window.show_all() sys.exit(gtk.main()) if __name__ == '__main__': gnomeapplet.bonobo_factory( 'OAFIID:GNOME_Starcal2Applet_Factory', gnomeapplet.Applet.__gtype__, core.APP_DESC, '0', starcalAppletFactory, )
--window, -w Launch the applet in a standalone window (default=no). """ sys.exit() if __name__ == "__main__": standalone = False try: opts, args = getopt.getopt(sys.argv[1:], "hw", ["help", "window"]) except getopt.GetoptError: opts = [] args = sys.argv[1:] for o, a in opts: if o in ("-h", "--help"): usage() elif o in ("-w", "--window"): standalone = True if standalone: import gnome gnome.init(PACKAGE, VERSION) newsticker_window() gtk.main() else: gnomeapplet.bonobo_factory('OAFIID:GNOME_NewsTicker_Factory', gnomeapplet.Applet.__gtype__, 'newsticker', '0.1', newsticker_factory)
def showmenu(a): g.ToggleMenu() if len(sys.argv) == 2: if sys.argv[1] == "run-in-window" or sys.argv[1] == "run-in-console": # Start the applet in windowed mode main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) main_window.set_decorated(1) main_window.set_title("GnoMenu Testing Sandpit") main_window.connect("destroy", gtk.main_quit) app = gnomeapplet.Applet() GnoMenu(app,"") app.reparent(main_window) main_window.show_all() gtk.main() sys.exit() if __name__ == '__main__': gnomeapplet.bonobo_factory( "OAFIID:GNOME_GnoMenu_Factory", gnomeapplet.Applet.__gtype__, "GnoMenu", "2", GnoMenu_factory)
#!/usr/bin/env python import pygtk pygtk.require('2.0') import gtk import gnomeapplet import subprocess def lyriczilla_applet_factory(applet, iid): socket = gtk.Socket() applet.add(socket) subprocess.Popen(['lyriczilla-nest', str(socket.get_id())]) socket.set_size_request(400, 20) applet.show_all() return gtk.TRUE gnomeapplet.bonobo_factory('OAFIID:LyricZilla_Applet_Factory', gnomeapplet.Applet.__gtype__, "LyricZillaApplet", "0", lyriczilla_applet_factory)