1ObjScanner(3)         User Contributed Perl Documentation        ObjScanner(3)
2
3
4

NAME

6       Tk::ObjScanner - Tk data scanner
7

SYNOPSIS

9         # regular use
10         use Tk::ObjScanner;
11
12         my $scanner = $mw->ObjScanner( -caller => $object,
13                                        -title=>"windows") -> pack ;
14
15         my $mw -> ObjScanner
16         (
17          -caller          => $object,
18          -title           => 'demo setting the scanner options',
19          -background      => 'white',
20          -selectbackground => 'beige',
21          -foldImage       => $mw->Photo(-file => Tk->findINC('folder.xpm')),
22          -openImage       => $mw->Photo(-file => Tk->findINC('openfolder.xpm')),
23          -itemImage       => $mw->Photo(-file => Tk->findINC('textfile.xpm')),
24         )
25         -> pack(-expand => 1, -fill => 'both') ;
26
27         # non-intrusive scan style
28
29         # user code to produce data
30         Tk::ObjScanner::scan_object($mydata) ;
31         # resume user code
32

DESCRIPTION

34       The scanner provides a GUI to scan the attributes of an object. It can
35       also be used to scan the elements of a hash or an array.
36
37       This widget can be used as a regular widget in a Tk application or can
38       be used as an autonomous popup widget that will display the content of
39       a data structure. The latter is like a call to a graphical
40       Data::Dumper. The scanner can be used in an autonomous way with the
41       "scan_object" function.
42
43       The scanner is a composite widget made of a menubar and Tk::HList.
44       This widget acts as a scanner to the object (or hash ref) passed with
45       the 'caller' parameter. The scanner will retrieve all keys of the
46       hash/object and insert them in the HList.
47
48       When the user double clicks on a key, the corresponding value will be
49       added in the HList.
50
51       If the value is a multi-line scalar, the scalar will be displayed in a
52       popup text window. Code ref will be deparsed and shown also in the pop-
53       up window.
54
55       Tied scalar, hash or array internal can also be scanned by clicking on
56       the middle button to open them.
57
58       Weak references are recognized (See WeakRef for details)
59

Autonomous widget

61   scan_object( data )
62       This function is not exported and must be called this way:
63
64         Tk::ObjScanner::scan_object($data);
65
66       This function will load Tk and pop up a scanner widget. When the user
67       destroy the widget (with "File -" destroy> menu), the user code is
68       resumed.
69

Constructor parameters

71       "caller"
72           The ref of the object or hash or array to scan (mandatory). (you
73           can also use '"-caller"')
74
75       "-title"
76           The title of the menu created by the scanner (optional)
77
78       "-background"
79           The background color for subwidgets (optional)
80
81       "-selectbackground"
82           The select background color for HList (optional)
83
84       "-itemImage"
85           The image for a scalar item (optional, default 'file.xbm')
86
87       "-foldImage"
88           The image for a composite item (array or hash) when closed
89           (optional, default 'folder.xbm')
90
91       "-openImage"
92           The image for a composite item (array or hash) when open (optional,
93           default 'openfolder.xbm')
94
95       "-show_menu"
96           ObjScanner can feature a menu with 'reload' button, 'show tied
97           info', 'view pseudo-hash' check box. (optional default 0).
98
99       "-destroyable"
100           If set, a menu entry will allow the user to destroy the scanner
101           widget. (optional, default 1) . You may want to set this parameter
102           to 0 if the destroy can be managed by a higher level object. This
103           parameter is ignored if show_menu is unset.
104
105       "-view_pseudo"
106           If set, will interpret pseudo hashes as hash (default 0). This
107           option is disabled for Perl 5.09 and later.
108
109       "-show_tied"
110           If set, will indicate if a variable is a tied variable. You can see
111           the internal data of the tied variable by double clicking on the
112           middle button. (default 1)
113

WIDGET-SPECIFIC METHODS

115   updateListBox
116       Update the keys of the listbox. This method may be handy if the scanned
117       object wants to update the listbox of the scanner when the scanned
118       object gets new attributes.
119

CAVEATS

121       The name of the widget is misleading as any data (not only object) may
122       be scanned. This widget is in fact a DataScanner.
123
124       ObjScanner may fail if an object involves a lot of internal perl magic.
125       In this case, I'd be glad to hear about and I'll try to fix the
126       problem.
127
128       ObjScanner does not detect recursive data structures. It will just keep
129       on displaying the tree until the user gets tired of clicking on the
130       HList items.
131
132       There's no sure way to detect if a reference is a pseudo-hash or not.
133       When a reference is believed to be a pseudo-hash, ObjScanner will
134       display the content of the reference like a hash. If the reference is
135       should not be displayed like a pseudo-hash, you can turn off the
136       pseudo-hash view with the check button on the top right of the widget.
137
138       Aynway, pseudo-hashes are deprecated from perl 5.8.0. Hence they are
139       also deprecated in ObjScanner.
140
141       The icon used for tied scalar changes from scalar icon to folder icon
142       when opening the object hidden behind the tied scalar (using the middle
143       button). I sure could use a better icon for tied items. (hint hint)
144

THANKS

146       To Rudi Farkas for all the improvements provided to ObjScanner.
147
148       To Slaven Rezic for:
149
150       ·   The propotype code of the pseudo-hash viewer.
151
152       ·   The idea to use B::Deparse to view code ref.
153

AUTHOR

155       Dominique Dumont, dominique.dumont@hp.com
156
157       Copyright (c) 1997-2004,2007 Dominique Dumont. All rights reserved.
158       This program is free software; you can redistribute it and/or modify it
159       under the same terms as Perl itself.
160

SEE ALSO

162       perl, Tk, Tk::HList, B::Deparse
163
164
165
166perl v5.12.0                      2007-10-09                     ObjScanner(3)
Impressum