Write GUI faster -> GCL

A goal that set my juices to flow is to make Perl a first class GUI language. Like back in the days even hardcore Java people took TCL to whip up a small graphical frontend app. This should now be done in Perl, because Perl can be simple but powerful when you need it. It just lacks some nice sugar to get a Gui fast. And GCL is my attempt to achieve that.

After talking about on several it for several years on Perl workshops and YAPC I finally started to really work on it. I mean some libs were there for over a year inside the Kephra editor but like a had now a burst of tuits, maybe because i got some from Wendy.

And it went rather fast because I thought about it for longer time and its actually no that much code needed (for now.) Being that an first appetizer judge for yourself. Here is the GUI of my latest graphical toy, the Harmonograph (repo) (post about that is pending)and the GCL code I wrote to assemble the GUI.

View image (please see popup for real proportions)

$frame->SetSmartLayout(
	[   # left part
		$app->{'maltafel'},
		10,
		{border => 10, flags => &Wx::wxGROW|&Wx::wxALL},
		$app->{'favorites'},
		[
			$button{'Speichern'},
			\1,
			{border => 10, flags => &Wx::wxLEFT|&Wx::wxRIGHT},
			$button{'Vergessen'}, 
			{border => 0},
			$button{'Merken'}
		],
	],[ # right half
		{border => 5, flags => &Wx::wxGROW|&Wx::wxALL},
		-box => ['Frequenz',      [$app->{'freq_x'},   $app->{'freq_y'}, $app->{'y_invers'}]],
		-box => ['Startamplitude',[$app->{'amp_x'},    $app->{'amp_y'}   ]],
		-box => ['Rotation',      [$app->{'rota_dir'}, $app->{'rota'}    ]],
		{border => 10},
		$app->{'friction'},
		$app->{'length'},
		$app->{'dense'},
		$app->{'zoom'},
		{border => 5},
		-box => ['Farbe', [$app->{'flow_c'},  $app->{'scale_c'}]],
	]
);

7 Comments

Android apps have this interesting idea where you can write the GUI layout in XML, and then it's compiled into a Java source file. Your code can grab and manipulate the widgets further from there. Programming it is something like the HTML/JavaScript relationship.

Something like that would be really cool to see in Perl.

Yeah Timm, but then you'd be dealing with XML files and some of us program in Perl, in part, to avoid XML Hell. ;-)

What about using QML (from Perl)?

If we're talking about XML files for building GUIs, there is also Glade for Gtk+.

Also Gtk2::Ex::FormFactory or (newer) Gapp, or Tk::QuickTk have similar syntaxes, but I think a less method syntax heavy soluction like Tickit::DSL might be better.

Leave a comment

About lichtkind

user-pic Kephra, Articles, Books, Perl, Programming