Home Page   the Perl Page   Programming and Computer Reviews   and Thailand Comments

Snatch GUI programming

use Win32::GUI;             snatch    dtd    IE5 & OLE    subs    XML examples   

integrating Snatch with Win32::GUI

Did I mention this is all BETA?

Snatch looks for a $sys{'gui'} reference and runs it. Setting gui=GT1.pl on the command line is the usual way to do this but you can also set the environment with SET SNATCH=gui+GT1.pl before running Snatch if that gets tiresome.
Snatch runs the GUI as a do before going into its usual loop. Like this:
Init();
do $sys{'gui'} if defined $sys{'gui'};
while ( 1 ) {
last if not &nextLink and not &checkAlarms;
&checkPage;
&parse;
&checkItems;
&checkFooter if $sys{'page'};
&checkAlarms;
}

The GUI obviously must provide a way to do these things, so that you can step through each item. Like a debugger. A fairly obvious beginning :-).

GT1.pl .. Snatch Debugger

This is the current standard debugger for Snatch. Complete enough to be useful
module alone GT1.pl (19 kb) Thursday, March 23, 2000
packaged with the bitmaps (yes you need the bitmaps) and wTV.pl, the treeview module. gt1.zip (14k)
Run it like this:
C:\perl\snatch\perl snatch.pl report.xml gui=GT1.pl

s1base.pl

module s1base.pl Thursday, March 23, 2000
Bare window with a close button.
The window is aligned to the top of the console box

wTV.pl

module
wTV.pl (20 kb) Thursday, March 23, 2000
with bitmaps wTV.zip (7 kb)
This hooks the treeview into the %sys hash, useful for debugging, And loads up the Data Structures Cookbook examples to start with.
A second way to load the treeview is with the output of File::Find
And of course you can load it again including file date and time
Finally there is Treeview and Browser working together. Click on an HTML file and IE5 comes along to display it. And the Treeview has the DOM structure on display, or some of it anyway. Couple of holes in in the DOM (sigh).
this is messy code!
I'll be cleaning it up some but it has several experiments and is not all that pretty. You've been Warned. :-)

Notes on GUI design

wTV.pl runs with GT1.pl very nicely.
wTV.pl also runs stanalone with considerable ease. Uncommenting one line of code does it.
Generally the Win32::GUI stuff isn't very hard to work with and is fairly lightweight.

SnatchGUI.pm

GUI, and Win32, centric code.
guiTitle sets the window title.
FindWindowByTitle returns the handle of a window with a particular title.
synch aligns the active window and the console box. At present his puts the console beneath a GUI window of the same width. Some code to keep them both on top is available.
synch takes a hash ref, usually \%GUI, and stuffs the hash with some values. Right now the thinking is to have each window have its own %GUI hash and put them on a list so everything gets terminated cleanly.