PenguinTVActivity.py :  » RSS » PenguinTV » PenguinTV-4.1.0 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » RSS » PenguinTV 
PenguinTV » PenguinTV 4.1.0 » PenguinTVActivity.py
import sys, os, logging
import gtk, gobject
from sugar.activity import activity

import hulahop

#need to set things up before we import penguintv

activity_root = activity.get_bundle_path()
  
#chdir here so that relative RPATHs line up ('./lib')
os.chdir(activity_root) 
  
#append to sys.path for the python packages
sys.path = [activity_root,] + sys.path

try:
  import pycurl
except:
  logging.warning("Trying to load bundled pycurl libraries")
  
  #append to sys.path for the python packages
  sys.path.append(os.path.join(activity_root, 'site-packages'))
  
  #try again. if it fails now, let it fail
  import pycurl 
os.environ['SUGAR_PENGUINTV'] = '1' #set up variable so that utils knows we are running_sugar

from penguintv import penguintv

class PenguinTVActivity(activity.Activity):
  def __init__(self, handle):
    activity.Activity.__init__(self, handle)
    app = penguintv.PenguinTVApp(self)
    self.set_title('News Reader')
    toolbox = activity.ActivityToolbox(self)
    
    #toolbox.add_toolbar(_('Feeds'), app.main_window.toolbar)
    app.connect('app-loaded', self.add_toolbar, toolbox)
    #gobject.idle_add(self.add_toolbar, toolbox, app)
    
    self.set_toolbox(toolbox)
    toolbox.show()
    self.connect('destroy',self.do_quit, app)
  
  def do_quit(self, event, app):
    app.do_quit()
    logging.info('deleting app now')
    del app
    
  def add_toolbar(self, app, toolbox):
    toolbox.add_toolbar(_('Feeds'), app.main_window.toolbar)
    

if __name__ == '__main__': # Here starts the dynamic part of the program

  def do_quit(self, event, app):
    app.do_quit()

  window = gtk.Window()
  gtk.gdk.threads_init()
  app = penguintv.PenguinTVApp(window)
  window.connect('delete-event', do_quit, app)
  gtk.main()
  
def main(): #another way to run the program

  def do_quit(self, event, app):
    app.do_quit()

  window = gtk.Window()
  gtk.gdk.threads_init()
  app = penguintv.PenguinTVApp(window)
  window.connect('delete-event', do_quit, app)
  gtk.main()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.