3 package Pod::Perldoc::ToTk;
7 use base qw(Pod::Perldoc::BaseTo);
10 sub write_with_binmode { 0 }
11 sub output_extension { 'txt' } # doesn't matter
12 sub if_zero_length { } # because it will be 0-length!
13 sub new { return bless {}, ref($_[0]) || $_[0] }
15 # TODO: document these and their meanings...
16 sub tree { shift->_perldoc_elem('tree' , @_) }
17 sub tk_opt { shift->_perldoc_elem('tk_opt' , @_) }
18 sub forky { shift->_perldoc_elem('forky' , @_) }
21 use File::Spec::Functions qw(catfile);
24 die join '', __PACKAGE__, " doesn't work nice with Tk.pm verison $Tk::VERSION"
25 if $Tk::VERSION eq '800.003';
27 BEGIN { eval { require Tk::FcyEntry; }; };
30 # The following was adapted from "tkpod" in the Tk-Pod dist.
34 my($self, $Input_File) = @_;
35 if($self->{'forky'}) {
36 return if fork; # i.e., parent process returns
39 $Input_File =~ s{\\}{/}g
40 if Pod::Perldoc::IS_MSWin32 or Pod::Perldoc::IS_Dos
45 $tree = $self->{'tree' };
46 $tk_opt = $self->{'tk_opt'};
48 #require Tk::ErrorDialog;
50 # Add 'Tk' subdirectories to search path so, e.g.,
51 # 'Scrolled' will find doc in 'Tk/Scrolled'
54 push @INC, grep -d $_, map catfile($_,'Tk'), @INC;
57 my $mw = MainWindow->new();
58 #eval 'use blib "/home/e/eserte/src/perl/Tk-App";require Tk::App::Debug';
61 # CDE use Font Settings if available
62 my $ufont = $mw->optionGet('userFont','UserFont'); # fixed width
63 my $sfont = $mw->optionGet('systemFont','SystemFont'); # proportional
64 if (defined($ufont) and defined($sfont)) {
65 foreach ($ufont, $sfont) { s/:$//; };
66 $mw->optionAdd('*Font', $sfont);
67 $mw->optionAdd('*Entry.Font', $ufont);
68 $mw->optionAdd('*Text.Font', $ufont);
71 $mw->optionAdd('*Menu.tearOff', $Tk::platform ne 'MSWin32' ? 1 : 0);
74 '-file' => $Input_File,
75 (($Tk::Pod::VERSION >= 4) ? ('-tree' => $tree) : ())
78 # xxx dirty but it works. A simple $mw->destroy if $mw->children
79 # does not work because Tk::ErrorDialogs could be created.
80 # (they are withdrawn after Ok instead of destory'ed I guess)
83 $mw->repeat(1000, sub {
84 # ErrorDialog is withdrawn not deleted :-(
85 foreach ($mw->children) {
86 return if "$_" =~ /^Tk::Pod/ # ->isa('Tk::Pod')
96 exit if $self->{'forky'}; # we were the child! so exit now!
106 Pod::Perldoc::ToTk - let Perldoc use Tk::Pod to render Pod
110 perldoc -o tk Some::Modulename &
114 This is a "plug-in" class that allows Perldoc to use
115 Tk::Pod as a formatter class.
117 You have to have installed Tk::Pod first, or this class won't load.
121 L<Tk::Pod>, L<Pod::Perldoc>
125 Sean M. Burke C<sburke@cpan.org>, with significant portions copied from
126 F<tkpod> in the Tk::Pod dist, by Nick Ing-Simmons, Slaven Rezic, et al.