My favorites | Sign in
Logo
                
Search
for
Updated Aug 30, 2007 by llpamies
GsocLlpamies  

I have created a branch in the pyjamas SVN.

You can browse online: http://pyjamas.googlecode.com/svn/branches/llpamies/

GSoC: Final Report

30th August

I have finally finished my GSoC (rev.452 from llpamies branch). I've been working this last week resolving some bugs and merging my GTK branch with the PyExternalModuke branch.

This example shows an example with both features working together. A simple GTK window with one button and one label is created. When the button is clicked, it executes the random.randint function at server side through a remote call and shows the result in the label.

import gtk
import random

class Test:
    def hello(self, widget, data=None):
        self.l.set_text( str(random.randint(10,20)) )

    def run(self):
        self.b = gtk.Button('Click me !')
        self.b.connect("clicked", self.hello, None)
        self.l = gtk.Label('null')
        self.h = gtk.VBox()
        self.h.add(self.b)
        self.h.add(self.l)
        self.w = gtk.Window()
        self.w.add(self.h)
        self.w.show_all()
        gtk.main()

if __name__=='__main__':
    t = Test()
    t.run()

Run:

$ cd pygtkweb
$ ./server.py examples/simple_button.py 

It looks like that: screenshoot.

I have reimplemented the PyExternalModule from scratch using JSONRPC. The reason to not use the existing JSONParser/JSONService was that they use a lots of old javascript backend functions that are not available in my current implementation.

Thanks to all people from pyjamas project that helped me with my work, and thanks to Google for GSoC program. I will continue working to improve pyjamas adding new gtk widgets and some new pyjs extensions that I've in mind.

Widgets, Widgets, Widgets ...

16th August

Two weeks has been passed since my last report. The reason is that I've been working in issues that can not be presented as a results. This issues includes:

  • GTK packaging system: I've spend many hours trying to get working the expand property in HBox and VBox child elements without successful results (I've some partial results). The main problem is that any solution is cross-browser compliant.
  • Signal/Event system: I've build a new signal/event system that allows each widget choose which DOM events it wants to catch and convert them to GTK equivalent events.
  • Implementing complex widgets from simple ones, like Button from Label, Image and Bin.

By now, in my last commit (rev.446) a very extended set of GTK widgets is working. Implemented classes:

  • Window
  • Widget
  • Table
  • Box
  • VBox
  • HBox
  • Bin
  • Container
  • Button
  • ToggleButton
  • CheckButton
  • RadioButton
  • Label
  • Image
  • Hseparator
  • VSeparator
  • Separator
  • OptionMenu
  • MenuItem
  • Item
  • Menu
  • MenuShell

My actual work is to get the 011 pygtk example working. You can see the partial results in my blog as screenshots.

The target for the next week (GSoC Final Evaluation) is to get the 011 pygtk example working (Range, HScrollbar, VScrollbar, Range, Scale, VScale, HScale, Adjustment) and merge the actual code with the RPC system for system modules.

More GTK Widgets

1st August

This last week I have been working with the GTK internals: signals, events, containers; and implementing widgets in HTML.

A widget is composed of a DIV called widget_cont with the following style properties: position: absolute; top: 0px; bottom: 0px; right: 0px; left: 0px;. Inside it we can place any other widget using a relative position and a percentage for the top, bottom, left and right properties. Additionally the Container widgets has another DIV inside, called widget_int that fills the 100% of widget_cont and allows the insertion of other containers in it.

This is the list of working pygtk examples:

002-base.py
003-helloworld.py
004-helloworld2.py
006-table.py
007-buttons.py
008-togglebutton.py
009-checkbutton.py
010-radiobuttons.py

GTK Work and development roadmap

22th July

This week I have added support for callables and lambda functions in pyjs.

In the pygtkweb/examples I've copied the pygtk examples from pygtk tutorial. The STATUS file in the same directory reflect the pygtk examples that my server can run.

The GTK work has been focused on:

  • GObject
  • Window
  • Events / Callbacks
  • Containers (Table, HBox, BVox...)
  • Button

I will try to run one by one the pygtk examples. This will be my roadmap.

New JS backend implemented and first steps with GTK

16th July

JS Backend

I have implemented the new JS backend for Pyjamas that I proposed in my last update. With this new backend pyjs accepts more python features and the resulting JS code is more simple, readable and pythonic !!.

Pythonic JS:

  • Function and class arguments are passed now inside two structures, the first one for normal arguments and the second one for unordered arguments:
  •    function_call([a,b],{c:'test'});
  • No more "new" words. To create new objects is only necessary to call the class name:
  •    obj = ClassName([],{});
  • New instances of [].{},"" objects are now python builtin objects:
  •    a = dict();
       a = {};
       s = str('aaa');
       s = ",".join(...);
  • Methods can be called directly over objects or Classes. There is no difference between it:
  •    a = A()
       a.sum([12,24],{}) == A.sum([a, 12, 24], {})

New python features supported:

  • Multi-inheritance
  • isinstance()
  • Native support for @staticmethod and @classmethod
  • We can use the "self" argument directly.
  • Support for star and dstar arguments (*args and **kargs).
  • Decorators support. Name decorators and function call decorators supported.
  • Merged all builtins in the same file. Auto-loaded by pyjs.
  • Added __dict__, __getattr__, __setattr__, __class__, __name__ to objects and classes.

Please, take a look and tell me what you think. It can be improved !!

First GTK steps

I am able to run this gtk code:

import gtk

def hello(self, widget, data=None):
    print "Hello World"

asa=hello

if __name__=='__main__':
    w = gtk.Window()
    b = gtk.Button('Click me !')
    b.connect("clicked", hello, None)
    b.connect("clicked", asa, None)
    w.add(b)
    w.show_all()
    gtk.main()

I have created a new browser.py library and a new gtk.py to be independent of GWT. You can run the above gtk code without any GWT code line.

To run the example:

$ cd pygtkweb
$ ./server.py examples/simple_button.py

And browse to http://localhost:9000/app/index.html.

Proposal for JS backend: multi-inheritance and decorators

11th July

I have been working on the GTK object hierarchy creating some containers and a couple of widgets. The problem is that pyjs can't compile correctly some fundamental pieces of code. I have been thinking in how to improve the pyjamas JS backend to support for example muti-inheritance, decorators, staticmethods and classmethods, better treatment for "self" argument, etc. This is my proposal: JsBackendProposal.

Scoping support for pyjamas

8th July

  • I have implemented scoping support to pyjamas to allow references between modules.
  • The server folder has been moved to pygtkweb and the server.py application now acts automatically as an autoloader, wrapping code in a onModuleLoad method.
  • I will start to code some GTK widgets and debug the possible pyjs bugs.

Direct application loader

26th June

To run a simple pygtk application we need to let pyjs compile and run code without defining the onModuleLoad method. I've added a loader.py in the builder folder to wrap code inside na onModuleLoad method and send it to pyjs.

Now you can compile this code:

from ui import Button, RootPanel
import Window
import random

def greet(sender):
    r = random.randint(1,13)
    Window.alert("The random number is: "+r)

b = Button("Click me", greet)
RootPanel().add(b)

directly using the -l option:

$ ./server.py -l ../examples/remotetest/Direct.py

Embedded server and external modules

22th June

The embedded server allows you to convert a python application and serve it in a simple HTTP server in one single step:

$ cd server/
$ ./server.py ../examples/kitchensink/KitchenSink.py

Once you see "Done" on the screen, browse to http://localhost:9000/app/KitchenSink.html to run the application.

The embedded server has been designed to support external modules use in pyjamas. Think about this pyjamas code:

from ui import Button, RootPanel
import Window
import random

def greet(sender):
    r = random.randint(1,13)
    Window.alert("The random number is: "+r)

class Hello:
    def onModuleLoad(self):
        pass
        b = Button("Click me", greet)
        RootPanel().add(b)

My task consists on convert the random module calls into JSONRPC calls to the embedded server. The server will be the responsible to import the required module and execute the function.

The actual pyjamas implementation converts the python code directly to javascript, without checking if the used tokens (var names, class names, function and methods names) exists in the python code. Because I needed to know witch modules or methods had to been converted to JSON calls some stuff has been added to the actual pyjs.py implementation.

To run the previous example just type:

$ cd server/
$ ./server.py ../examples/remotetest/Hello.py

And browse to: http://localhost:9000/app/Hello.html

To do:

  • Allow access to module class instantiation.
  • Allow return complex types generated in the server and use it later. Conceptual unit test:
  •    f = file('test.txt',w)
       f.write('Hello')
       f.close()


Sign in to add a comment
Hosted by Google Code