[maemo-developers] New project idea, pygtk questions, and a toolkit

From: Sean Luke sean at cs.gmu.edu
Date: Mon Feb 19 19:41:15 EET 2007
Hi all.  I've been playing with pygtk and mulling over what project I  
should start.  I think I'll do something small to get my feet wet,  
but I do have a direction based on an immediate need of mine which I  
can't find an existing maemo app for.

I'm thinking of ultimately doing a drag-and-drop hypercard-like form  
database tool.  Which you can customize for whatever you want:  
recipes, contact lists, your CD collection, location of archeological  
finds, you name it.  I used to do a lot of hypercard coding and miss  
this badly; and my cursory glance of the maemo apps suggests there  
may be a bit of a hole there.  Some questions:

- Is there an existing app which does this?
- I'm aware of pythoncard, but it relies on wxwidgets.  How's the  
wxwidget port coming along?
- There are several Java apps which do this.  How's CLASSPATH coming  

And now some pygtk questions.  Okay, mostly rants.  But rants that I  
*hope* I am ignorant about and can then apologize for.  pygtk is a  
pretty well-done cover over GTK, but GTK is irritating.  :-(

- Why is there any distinction between events and signals?

- There appears to be no hook for gtk.Paned to detect when the user  
is moving / has moved the divider bar.  This would seem to me to be  
the single most important hook.  The only option I've found online is  
to override the size change hook  Am I missing something?

- How do you create a gtk.Slider which has ticks at 0, 3, 6, 9, ...?   
It appears that the mechanism provided for gtk.Slider (its  
"Adjustment" object) is pretty bad.  So far as I can tell, short of  
overriding the display mechanism, you can only get ticks which are  
powers of 10.  hildon.Controlbar looks better but has less  
functionality.  Is there another widget to use?

- gtk.SpinButton is retarded.  It provides you with microscopic up/ 
down buttons on top of each other to fit within the vertical space of  
a text field, when it _should_ be giving you large buttons side-by- 
side in the form of <- ->.  It can also only add or subtract, not  
double or halve.  hildon.NumberEditor only provides integers so far  
as I can tell, and only add/subtract.  Is there another widget to use?

- python's string-formatting function *rounds* integers rather than  
truncating towards zero or flooring.  This makes it close to  
worthless for slider-like mechanisms, when an app gets 0.998... which  
it typically (in my experience) needs to cut to 0.99, while the user  
sees 1.0.  I'm fairly new to python.  Short of writing my own string  
formatter, is there a python function which will provide formatted  
strings from integers _truncated_ to a certain number of digits?

- Why is it in python that you can attach a function, and an instance  
variable, to an instance, but you cannot attach a method?  Or is  
there a mechanism I'm not aware of?  Second: can you make an  
anonymous function through any route than a lambda?  Because lambdas,  
weirdly, don't permit statements inside them.  In NewtonScript (and  
Self, and JavaScript I think) objects are just dictionaries -- as is  
the case for Python underneath -- and you can do this:

myButton := {
	_proto: protoButton,
	printme: func() begin
		print("hi there");
		print("I am " & self) end

I'd like to do this in python with the following equivalent (but  
invalid) syntax:

myButton= Button()
myButton.printme = lambda self:
			print("hi there")
			print("I am " + self)

Can someone more experienced in Python tell me why this can't be  
done, or if it can be done, how?

- How do I move the text in a gtk.Frame vertically?   It's set too  
close to the frame and descenders (g,q,p,y,j) collide with the frame  
border in an ugly fashion.

Last, partly in response to irritation with GTK, I've been at work  
making a lightweight cover library on top of pygtk.  The goal is to  
provide a minimum amount of functionality that's easier to use, but  
to let you dip down into pygtk when you need to.  Some items done:

- All stateful widgets (including gtk.Paned) have persistent state  
across application executions.

- A number of widgets provide the functionality of several gtk  
widgets at once.  Box provides both HBox and VBox functionality and  
also has a built-in gtk.Frame.  And Pack combines Alignment and  
Frame.    Button provides togglebuttons, regular buttons, and check  
buttons (that may be dumb, I may break them out).  Label allows for  
images as well.

- Detailed constructors.

- I'm replacing some widgets (SpinButton, Slider) with modified  
versions which have more functionality.

- Hooks are handled through method calls, not signals/events.  This  
permits both subclass hooks and cleaner MVC calls (through lambdas).

- [planned] a customizable button bar, stateful and column-modifiable  
treeview, and thicker scrollbars and split pane dividers.  And  
bigger, easier to read icons.

It's just a toy for now, to explore the toolkit.  And when it's done  
it'll hardly be bulletproof.  But I was wondering if there was  
interest in such a thing.


More information about the maemo-developers mailing list