I like pyglet a lot. Much more than a lot.
However, the lack of a compelling GUI toolkit for development purposes has been a major irritation of late. This week I finally sat down and wrote my own GUI toolkit, from scratch, and I am happy enough with the way it works to release a first version to the public.
simplui (in true programmer fashion, pronounced ‘simply’) is intended as a programmer’s GUI toolkit. It isn’t pretty at all, but it is very functional, and extremely simple – in short a perfect replacement for the endless lines of textual statistics currently scrolling down your terminal window…
There is a short demo (less than 100 lines of commented code) accompanying the source, which demonstrates most of the pertinent features.
# create dialogue, and immediately add it to the frame frame.add( Dialogue(50, 50, 200, 300, 'Inspector', content= # add a vertical layout to hold the window contents VerticalLayout(0, 0, 200, 100, padding=2, children=[ # now add some folding boxes FoldingBox(0, 0, 200, 100, 'stats', content= # each box needs a content layout VerticalLayout(0, 0, 200, 300, children=[ # add a text label, note that this element is named... Label(20, 20, '0.0 fps', name='fps_label'), # and this element is not named Label(20, 20, '10,000 triangles'), ]) ), FoldingBox(0, 0, 200, 100, 'settings', content= VerticalLayout(0, 0, 200, 300, children=[ # a checkbox, note the action function is provided directly Checkbox(20, 60, 'Show wireframe', action=check_action), # a text input field TextInput(20, 80, 160, 20, text='edit me', action=text_action) ]) ), FoldingBox(0, 0, 200, 100, 'misc', content= # We need to name this layout, because we used it in the callback above VerticalLayout(0, 0, 200, 300, name='misc_layout', children=[ # a random label Label(20, 40, 'Hello, World!'), # and a clickable button Button(20, 80, 80, 20, 'Click me!', action=button_action), ]) ) ]) ) )
And of course, you can change any and all of those attributes on the fly if you need to (including inside callbacks).
As usual, you can grab the code from the googlecode subversion server, or the release tarball. Please note that while the toolkit is quite user-friendly, the implementation code is an uncommented, and rather a mess – I would suggest the faint of heart avoid attempting modifications to this version.
Take a look and let me know what you think…