Parrot-0.0.1
Phil Hunt
philh at vision25.demon.co.uk
Mon Aug 23 21:16:13 EDT 1999
In article <7ps4ma$n06$1 at wagner.wagner.home>
vitus at wagner.rinet.ru "Victor Wagner" writes:
> 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.
If that is what you think, you obviously have a different aesthetic
sense than me.
Don't forget that Parrot will be able to do more than what is in that
simple example. For example:
sub.fcol=red
would mean ``make all components inside the current component
default to having an attribute ``fcol'' with thew value ``red''
(i.e red foreground); these defaults can be overridden by the
attributes in the actual components''
Creating a default attribute for a component-type will also
be possible, e.g:
all.label.font=Helvetica
> 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.
Could it write C output that calls the GTK+ library, or C++/Qt,
or other language/GUI-toolkit combinations?
> 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.
Would anyone want to do this in Tcl as opposed to Python? (Not
wishing to get into another language war :-)).
> And parrot files would become runnable. But pretty
> useless, becouse I've not seen any way to attach functionality to these
> windows.
Use subclassing.
--
Phil Hunt....philh at vision25.demon.co.uk
More information about the Python-list
mailing list