simplui v1.0 released

A quick demo of simplui's controls and capabilities.

A quick demo of simplui's controls and capabilities.

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.

From my point of view, the nicest feature is that one can create an entire GUI with a single python statement. Note that we can assign element names (which can later be used to retrieve the element, à la javascript ids) as well as action callbacks, directly in the constructors:

# 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…



    • I initially planned to modify PyWidget, but having looked at the code, it just wasn’t designed to do the sort of things I needed.

      In particular, there was no simple way to add focusing of widgets (necessary for text input controls) or to add dynamic widgets (my collapsible panels).

      Don’t get me wrong, PyWidget has a lot of potential, and I am sure it will mature into a solid GUI toolkit, but for the moment, simplui has the more solid feature set and friendlier API. PyWidget is certainly prettier, though 😉

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s