~richardjones/withgui/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
One thing that's always bugged me about Python GUIs is that they're  
always so damned verbose or fiddly to declare. Some way more than others.

Main Goals:

 - easy gui layout
 - handling of events
 - scheduling of future actions
 - regular actions (animation)
 - drawing (bitmap, SVG and manual)


The most basic withgui application, ``hello_world.py``::

    label('Hello, world!')

which is launched using ``withgui hello_world.py``.

If you wish to incorporate withgui into an existing Python program you may
import it::

    import withgui
    gui = withgui.Label('hello, world')
    gui.run()

The very first widget must be created by calling "withgui.<name>". By
convention we call this widget "gui".  Thereafter widgets will usually be
created by calling "gui.<name>".

The widgets available are (with their properties listed):

- label
  value, foreground, background, x, y, width, height
- image
  value, x, y, width, height
- text
  value, foreground, background, x, y, width, height
- button
  value, foreground, background, x, y, width, height
- selection
  value, foreground, background, x, y, width, height
- column
  x, y, width, height
- row
  x, y, width, height
- frame (no packing)
  x, y, width, height
- form
  x, y, width, height
- canvas
  x, y, width, height

All widgets may control how they are packed into their parent (unless they
are placed in a frame using x, y coordinates) using the parameters "anchor",
"fill" and "expand".

Canvas widgets may have contents created with:

    - image
    - text



IMPLEMENTATION LAYERS
---------------------


These must implement the folowing interface:

    class GUI(object):
        def __init__(self, spec):
            '''Accept a withgui spec and create a GUI implementation.
            '''

        def run(self):
            '''Run the gui.
            '''

        def stop(self, data=None):
            '''Stop the gui.
            '''
            ...
            return data

Each widget in the spec must be created and attached to the spec as the
"implementation" attribute. The "implementation" object must implement the
following interface:

    class Implementation(object):
        def set_property(self, name, value):
            '''Set the named property of this widget.
            '''
        def get_property(self, name):
            '''Get the named property of this widget.
            '''
        def destroy(self):
            '''Destroy me.
            '''


CURRENT IMPLEMENTATIONS
-----------------------

There's still heaps that could be done. The following is just the features
implemented or partially implemented. There's a ton of widgets not
implemented like sliders, checkboxes, etc. 

Y = all done
P = partial implementation
N = not done
B = broken / buggy
X = can't be done

----------------------- ------- ------- -------
Component               Tkinter kytten  simplui
----------------------- ------- ------- -------
Label                   Y       Y       Y
 - styling properties    P        N       N
 - can modify           Y         N       N
Button                  Y       Y         N
 - styling properties    P        N       N
 - can modify           Y         N       N
Row & Column            Y       Y         N
 - styling properties    P        N       N
 - image background        B      N       N
Frame                   Y       Y         N
 - styling properties    P        N       N
 - image background     Y         N       N
Text                    Y       Y         N
 - styling properties     N       N       N
 - can modify             Y       Y       N
Form                    Y         N       N
Selection               Y          B      N
 - styling properties     N       N       N
 - can modify             N       N       N
Form                    Y         N       N
Canvas                  Y         N       N
 - image                Y         N       N
 - text                 Y         N       N
 - mouse pick           Y         N       N
 - shapes                 N       N       N
Animation & after       Y         N       N
----------------------- ------- ------- -------