4 ms·
http://search.cpan.org/~michael/Class-Declarative-0.06/lib/Class/Declarative.pm http://search.cpan.org/~michael/Class-Declarative-0.06/lib/C... A declarative f
by Vivtek 16y ago
http://search.cpan.org/~michael/Class-Declarative-0.06/lib/Class/Declarative.pm http://search.cpan.org/~michael/Class-Declarative-0.06/lib/C...
A declarative framework for Perl that lets you set up complex data structures and code in an easy-to-read format.
A complete working example GUI program, using a not-yet-published set of semantic classes:
use Class::Declarative qw(Wx::Declarative);
dialog (xsize=250, ysize=110) "Wx::Declarative dialog sample"
field celsius (size=100, x=20, y=20) "0"
button celsius (x=130, y=20) "Celsius" { $^fahrenheit = ($^celsius / 100.0) * 180 + 32; }
field fahrenheit (size=100, x=20, y=50) "32"
button fahrenheit (x=130, y=50) "Fahrenheit" { $^celsius = (($^fahrenheit - 32) / 180.0) * 100; }
- koenigdavidmj 16y agoIs that...significant indentation in Perl? Will you marry me?
- Vivtek 16y agoWell, actually it's kind of like an unholy Python/Tcl mutant thing, since the one-word tag determines the parsing of its line and children - but yes, significant indentation using a Perl filter.
- cabalamat 16y agoI did something similar to that once -- a program that compiled GUI descriptions into a runable Python class, which could then be subclassed to provide functionality. The syntax looked like this: window @MyBigWindow "My Big Window" { menuBar { menu "File" { menuItem @New "New" menuItem @Open "Open..." menuItem @Save "Save" menuItem @Exit "Exit" } menu "Edit" { menuItem @Copy "Copy" menuItem @Cut "Cut" menuItem @Paste "Paste" } } rowLayout { button "Button 1" button "Button 2" button "Button 3" } } Laying out GUI components was done with the rowLayout, colLayout and table containers. The subclass would contain code to be executed for @New, @Open, @Save, etc.
- Vivtek 16y agoThere's some similar stuff for wx in Perl and Python, too - I've just been taking the time to (try to) be systematic about making things fast and easy to specify. I really, really get tired of coding all that stuff by hand every damn time - it's one of the major things that made me get out of GUI work in the first place, back in the Stone Age. I've got big plans, and since it's not expected to pay any bills for a while, I can afford to think things through sufficiently. I just hope I won't drop it entirely. It's been fun so far, though.
- cabalamat 16y ago> I really, really get tired of coding all that stuff by hand every damn time - it's one of the major things that made me get out of GUI work in the first place Absolutely. Having sensible and configurable defaults for everything is the way to go.