Parrot-0.0.1

Victor Wagner vitus at wagner.rinet.ru
Mon Aug 23 14:42:18 EDT 1999


Phil Hunt <philh at vision25.demon.co.uk> wrote:


: Parrot is a text-based GUI builder, written by Philip Hunt. It is 
: intended to be used by programmers writing GUI applications. To 
: use Parrot, first you create a *.par file describing your 
: application's GUI. Your file might look something like this:

Compare this with code below:
: -----------Cut here-------------------------------
: window @MyWindow "My First Window" {
:    menuBar {
:       menu "File" { 
:          menuItem @New "New" 
:          menuItem @Exit "Exit"
:       }
:       menu "Help" { 
:          menuItem @About "About..."
:       }
:    }
:    colLayout {
:       rowLayout {
:          label "First row!"
:          button @Button1 "Press me"
:          button @Button2 "And me"
:       }
:       rowLayout {
:          label "Which units:"
:          radioButton @inchRB "inches"
:          radioButton @feetRB "feet"
:          radioButton @yardRB "yards"
:          radioButton @mileRB "miles"
:       }
:    }
: }
: -----------Cut here-------------------------------


toplevel .mywindow -menu .mywindow.m; wm title .mywindow "My First Window"
menu .mywindow.m
  .mywindow.m add cascade -label "File" -menu .mywindow.m.file 
     menu .mywindow.m.file
        .mywindow.m.file  add command -label New -command new_file
        .mywindow.m.file add command -label Exit -command exit
  .mywindow.m add cascade -label "Help" -menu .mywindow.m.help
     menu .mywindow.m.help
        .mywindow.m.help add command -label About... -command about
frame .mywindow.f1
  label .mywindow.f1.l1 -text "First row"
  button .mywindow.f1.b1 -text "Press me" -command do_something
  button .mywindow.f1.b2 -text "And me" -command do_something_else
  pack .mywindow.f1.l1 .mywindow.f1.b1 .mywindow.f1.b2 -side left -padx 10
  
frame .mywindow.f2
 label .mywindow.f2.l1 -text "Which units:"
 # Here I got tired of typing and let the program produce rest
 pack .mywindow.f2.l1 -side left -padx 10
 foreach unit {inches feet yards miles} {
    radiobutton .mywindow.f2.$unit -text $unit -value $unit -variable unit
    pack .mywindow.f2.$unit -side left -padx 10
 }
pack .mywindow.f1 .mywindow.f2 -side top -pady 5 -anchor n

This is tcl/tk. Almost no difference. A bit more verbose, but there are
numerous ways to shorten code, which I haven't used intentionally until
I got tired and used a loop to produce four radiobuttons.

And this is not something which should be run through preprocessor.
This is already runnable code. Just add #!/usr/bin/wish at the beginning
and chmod +x it. And if you define procedures do_something ,
do_something_else and new_file, it may even do something useful.
Oh yes, there is empty default window floating around. I could create
all the widgets in it directly, but in original code it was obvoisly not
main window of program, so I choose to create separate toplevel.

Note also that all this things are done runtime, not when preprocessing,
so, for instance I could get list of units via database query or
substitute different lists according to current locale.

Once again: who need so-called GUI builders while we have scripting
languages, which provide same level of abstraction, but much more
flexibilty, becouse interface is created run-time? 

Really it is very simple to define parrot interpreter on tcl - just
define commands such as window, columnLayout, rowLayout as tcl procedures 
which substitute
something by default. And parrot files would become runnable. But pretty
useless, becouse I've not seen any way to attach functionality to these
windows.


-- 
--------------------------------------------------------
Victor Wagner @ home       =         vitus at wagner.rinet.ru 
I don't answer questions by private E-Mail from this address.




More information about the Python-list mailing list