Friday, September 25, 2009

Genius G-Pen 4500 and Fedora

Just bought a Genius G-Pen 4500 digitizer tablet for myself. Mainly for drawing simple sketches and diagrams. Got it for MYR160 (~=USD50), which is relatively cheap compared to other tablets (Wacom and Genius) I found at LowYat plaza which averages at MYR400-800 (~=USD115-230).



The driver for the tablet is not available in the Fedora and RPMFusion repos, so I had to grab the sources from LinuxGenius GoogleCode page and compile it. (I've put together a RPM here : http://izhar.fedorapeople.org/wizardpen/).

After installation of the driver, a HAL FDI configuration is required for it to work. Here's the default one I'm using for this tablet. (Save it as /etc/hal/fdi/policy/99-wizardpen.fdi)


<?xml version="1.0" encoding="ISO-8859-1" ?>
<deviceinfo version="0.2">
<device>
<!-- This MUST match with the name of your tablet -->
<match key="info.product" contains="UC-LOGIC Tablet WP5540U">
<merge key="input.x11_driver" type="string">wizardpen</merge>
<merge key="input.x11_options.SendCoreEvents" type="string">true</merge>
<merge key="input.x11_options.TopX" type="string">0</merge>
<merge key="input.x11_options.TopY" type="string">0</merge>
<merge key="input.x11_identifier" type="string">stylus</merge>
<merge key="input.x11_options.BottomX" type="string">32739</merge>
<merge key="input.x11_options.BottomY" type="string">32745</merge>
<merge key="input.x11_options.MaxX" type="string">32739</merge>
<merge key="input.x11_options.MaxY" type="string">32745</merge>


(copy paste that or download it here : 99-wizardpen.fdi)

Afterward restart Xorg, and connect the tablet, and it worked quite easily.

Reference: http://digitalbluewave.blogspot.com/2008/10/genius-wizardpen-with-intrepid-ibex.html

Aspect Ratio

By default, the driver utilizes the whole tablet for input, stretching X and Y axis to match the screen shape, thus breaking the aspect ratio. Might still be ok on small screens, but on dualscreen, the ratio stretched too far causing difficulty to draw/write.

Unlike the Wacom driver which have this feature by default, LinuxGenius doesnt have it, but the options in the FDI is enough to allow us to configure it manually. I've written a simple script for this (get it here: wizardpen-ratiocalc.py).

Edit the script and change the resolution value, and run it. The script will output a fdi config that uses the aspect ratio of your screen.

The result?



Sketched on Inkscape.

My initial overall view of this tablet?. Cheap, relatively easy enough to get it working based on my requirement, so I guess this should be good enough for my purposes.

^-^

Tuesday, September 15, 2009

"CSL G2" Android Phone ??? - New Toy in Town?

UPDATE: I have checked out this phone at a shop just recently, apparently, its only a UI imitation (which is not even close to the real thing, didnt see any tango icons). Guess I'll have to wait for LG or some company to release a low cost model, or until HTC reduce their pricing. (and note to anybody from CSL who might read this, Google Android is not just the UI .. its the WHOLE OS , and its Free/OpenSource, just grab it from http://source.android.com/)



CSL, a Malaysian phone brand looks like just had a new toy in town.



GEOGLE?? is that a typo or is that an immitation brand?

MYR 699 ~= USD 200.

Update: An anonymous commenter pointed to a page in CSL's own website regarding the phone. Price stated there is apparently cheaper, MYR499 ~= USD145



While the name is a straight copying of HTC Magic's original name, the product looks interesting. No info could be found at their website, probably they didn't realize where the people who looks for Android phones hang around at. Check it out here (page in Malay)

Perhaps this is the first arrival of affordable lines of Android phones.

Anybody know more info about it?


Update:

Specification

* Dual SIM support
* 240x400 resolution screen
* GSM 900/1800
* Size: 113x56x23mm
* Weight: 120g
* Standby time: 120hrs+
* On-Call time: 2.5hrs
* Camera, FM Radio, Bluetooth
* (optional) Islamic features : Al-Quran, Athan, Digital Compass

And the usual Android software features I guess

Monday, September 14, 2009

Grokking Grok - II

Grok, like Plone uses the Zope way of storing data - Persistence, somewhat like 'pickling' in Python.

All instance of objects are treated not as tables like in frameworks such as TurboGears, but as normal runtime class instance objects. There are no need to think of SQL, neither designing a database. Just dump the objects into the ZODB.

Base Model Stereotype

The are 3 main model stereotype in Grok, grok.Model , grok.Container , grok.Application

grok.Model

This is the stereotype for a persistence class. Classes that inherits this stereotype are addable and can store persistent data.

grok.Container

This stereotype give a class a folder-like ability to store children. Inherit from this class if you want to create objects which can store another object.

grok.Application

This is the stereotype of a persistence class which can be added at the root of the Zope3 site.

Layout

Siteroot may contain Applications, Applications may contain both Containers and Models, Containers may contain both Containers and Models.

Defining a simple Grok Model

Assumes you've created a project called MyProject. Edit $buildout/src/myproject/app.py. You should see something like this

import grok

class MyProject(grok.Application, grok.Container):
pass

class Index(grok.View):
pass


Lets create a simple grok.Container model which called MyFolder and a normal model called MyDocument. Add these into app.py

class MyFolder(grok.Container,grok.Model):
pass

class MyDocument(grok.Model):
pass


Done.

Writing a simple AddForm for adding objects

Grok provides some handy classes for automatically generating forms which based on zope.forms. So you can quickly generate a form using it. Lets create a form to add MyFolder into MyProject.

First, as we are going to have multiple Zope Views (forms are considered as views) in this app.py, Index class need to be modified a bit.

class Index(grok.View):
grok.context(MyProject)


By default, The context will be acquired from the only Model available in the .py file. But as this example have multiple models in the .py file, that need to be defined.

Next, define the fields which we want MyFolder to have (note: put this code above MyFolder class definition).

from zope.interface import Interface
from zope import schema

class IMyFolder(Interface):
name = schema.TextLine(title=u'Object Name')
title = schema.TextLine(title=u'Title')


As you can see, instead of adding the attributes into the MyFolder class, we created an Interface. Next, make MyFolder implement the Interface

class MyFolder(grok.Container,grok.Model):
grok.implements(IMyFolder)


Afterward, lets create a form

class MyFolderAddForm(grok.AddForm):
grok.context(MyProject)

form_fields = grok.AutoFields(IMyFolder)

@grok.action(u'Add MyFolder')
def add(self,**data):
mf = MyFolder()
self.applyData(mf,**data)
name = data['name']
self.context[name] = mf
self.redirect(self.url(mf))


Done. Up to this point, you now have an application called MyProject, and an addable model called MyFolder. Now to adjust the templates.

Edit $buildout/src/myproject/app_templates/index.pt and replace the template with this:


<html>
<head>
</head>
<body>
<h1>Welcome to My Application</h1>
<a href="myfolderaddform">Add MyFolder</a>
</body>
</html>


Creating a View for a Model

MyFolder at the moment does not have a default view template. So lets create one. Create a View by adding this:

class MyFolderView(grok.View): 
grok.context(MyFolder)
grok.name('index')


Then edit $buildout/src/myproject/app_templates/myfolderview.pt, and put this as the template:

<html>
<head>
</head>
<body>
This is a new MyFolder object called <tal:name replace="context/name"/>
with title '<tal:name replace="context/title"/>'
</body>
</html>


Done. You should now be able to add an application called MyProject, and add a MyFolder in it.

Running you application

Start Zope3

$buildout/bin/zopectl fg


Open http://localhost:8080/.




Add a MyProject, name it as testapp and open it.



Click the "Add MyFolder" link.




Add a new MyFolder object, name it as testfolder, afterward you should see this



Thats it for now. Try to add an AddForm for MyDocument by yourself.

More details?

Read the official tutorial here : http://grok.zope.org/doc/current/tutorial.html

Zope TAL Spec : http://wiki.zope.org/ZPT/TALSpecification14

Zope Component Architecture : http://www.muthukadan.net/docs/zca.html

Grok/Zope Forms : http://grok.zope.org/documentation/phc_topic_area?topic=Forms

Have fun

Grokking Grok

*yawn*.. been a while since I last posted anything technical here. So some update.

I just started playing with Grok while trying to understand more on Zope3 stuff. So this post and the next few posts will focus mainly on Grok and how to do stuff on it (from my understanding).

Installing Grok

Using buildout, here's the buildout.cfg:

[buildout]
parts = grok
download-cache = downloads

[grok]
recipe = zc.recipe.egg
eggs =
grokproject



Using virtenv / normal python

easy_install-2.4 grokproject


Creating a Grok Project

grokproject --zopectl [projectname]


That command will create another buildout with grok and zope3.

Thursday, September 03, 2009

FOSS.my 2009!

fossmy-logo


FOSS.my 2009 is back and is coming your way this 24th and 25th of October .
The registration page is up and accepting registrations now. Check out the pricing below.

Registration Type Closing Date Price (RM)
Early Bird Price 30th September 2009 RM 88.00
Early Bird Group Registration 30th September 2009 RM 440.00
Regular Price 23rd October 2009 RM 127.00
Walk-in Price 24th/25th October 2009 RM 150.00

The price is slightly more then last year’s RM50 but it’s worthwhile I feel. Check out what you get, check out the schedule.
  1. 32 Talks
  2. 26 Speakers
  3. Double track sessions all day long
  4. Bird-Of-Feather side sessions
  5. A Tee Shirt
  6. Lunch
  7. 2 Tea breaks

Register for FOSS.my 2009 now!
Make sure to stay up to date with FOSS.my 2009 through either channels shown below;
FOSS.my 2009 Home
FOSS.my 2009 on Facebook
FOSS.my 2009 on Twitter