Shell.py :  » Ajax » pyjamas » src » examples » shell » 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 » Ajax » pyjamas 
pyjamas » src » examples » shell » Shell.py
import pyjd

from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.Controls import VerticalDemoSlider
from pyjamas import Window
from pyjamas.Timer import Timer
from textconsole import TextWindow
from Screen import Screen

try:
    import pyjslib
except:
    pass
import sys

def slider_app():
    b = VerticalDemoSlider(0, 100)
    b.setWidth("20px")
    b.setHeight("100px")
    return b

def text_app():
    w = TextWindow(80, 20, 400, 300)
    RootPanel().add(w)
    w.setText(0, 0, "hello")
    w.setText(0, 1, "fred")
    w.setText(0, 5, "goodbye")
    for i in range(40):
        for j in range(2):
            w.setText(i, j+10, ".")
    return w


class ShellApp():
    def __init__(self):

        self.GridTest = None

        self.screen = Screen(Window.getClientWidth(), Window.getClientHeight())
        w = text_app()
        a = self.screen.add_app(w, "text 1", 400, 300)
        a.show()
        w = text_app()
        a = self.screen.add_app(w, "text 2", 400, 300)
        a.show()
        w = slider_app()
        a = self.screen.add_app(w, "s", 20, 100)
        a.show()

        RootPanel().add(self.screen)

        self.loading_apps = []
        self.loading_app = None
        self.loading_desc = None

        self.load_app('../../gridtest/output/', 'GridTest', 'grid test')
        self.load_app('../../widgets/output/', 'Widgets', 'clock')

    def load_app(self, path, appname, description):
        if self.loading_app is None:
            self.add_app(path, appname, description)
        else:
            self.loading_apps.append((path, appname, description))

    def add_app(self, path, appname, description):

        self.loading_app = appname
        self.loading_desc = description

        try:
            sys.setloadpath(path)
            pyjslib.preload_app_modules(sys.getloadpath(), [[appname]],
                                        self, 1, None)
        except:
            pass

    def onTimer(self, timerid):
        self.importDone()

    def importDone(self):

        mod = pyjslib.get_module(self.loading_app)
        if mod is None:
            Timer(500, self)
            return

        g = mod.AppInit()
        a = self.screen.add_app(g, self.loading_desc, 400, 300)
        a.show()
    
        self.loading_desc = None
        self.loading_app = None

        if self.loading_apps:
            path, appname, description = self.loading_apps.pop()
            self.add_app(path, appname, description )

if __name__ == '__main__':
    pyjd.setup('./public/Shell.html')
    app = ShellApp()
    pyjd.run()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.