|
GsocLlpamies
I have created a branch in the pyjamas SVN. You can browse online: http://pyjamas.googlecode.com/svn/branches/llpamies/ GSoC: Final Report30th 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:
By now, in my last commit (rev.446) a very extended set of GTK widgets is working. Implemented classes:
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 Widgets1st 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 roadmap22th 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:
I will try to run one by one the pygtk examples. This will be my roadmap. New JS backend implemented and first steps with GTK16th July JS BackendI 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_call([a,b],{c:'test'}); obj = ClassName([],{}); a = dict();
a = {};
s = str('aaa');
s = ",".join(...); a = A()
a.sum([12,24],{}) == A.sum([a, 12, 24], {})New python features supported:
Please, take a look and tell me what you think. It can be improved !! First GTK stepsI 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 decorators11th 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 pyjamas8th July
Direct application loader26th 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 modules22th 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:
f = file('test.txt',w)
f.write('Hello')
f.close()
|
Sign in to add a comment