[tcltk-perl] radical rethink of Tk's loading ... (no C)
Brought to you by:
hobbs
From: Jeff H. <je...@Ac...> - 2004-04-28 23:30:04
|
Here is an idea I have about changing around Tcl::Tk, and it's fairly fundamental: Change Tcl::Tk::new as follows: $i->SUPER::Init(); - $i->Init(); + #$i->Init(); + $i->Eval("package require Tk 8.4"); + $i->call('trace', 'add', 'command', '.', 'delete', + sub { $W{'.'} = undef; }); + $i->ResetResult(); $Tcl::Tk::TK_VERSION = $i->GetVar("tk_version"); and then add the following command: sub MainLoop { my $int = (ref $_[0]?shift:$tkinterp); while (defined $W{'.'}) { $int->DoOneEvent(0); } } The one thing this requires is the addition of Tcl_DoOneEvent to Tcl.xs (which I did for testing this). Everything seems to work just fine after these changes. I had to make a few more to force the Tk module on Linux not to load the dll (which isn't necessary in any case, but I haven't fully excised it from the build), but the crux of the changes work. This means that the only C component is on the Tcl side - there is NO Tk C component, only Tk.pm. The loading an initialization of Tk is build into the 'package require Tk' statement. The disadvantage here is removing any access at the C level to Tk stuff, but currently there is nothing there we use. At the same time, I have a patch which adds Tcl stubs support to the Tcl module. That means we gain Tcl version independence and have more control over what Tcl is used at runtime. More on that here: http://aspn.activestate.com/ASPN/docs/ActiveTcl/tcl/TclLib/InitStubs.htm Jeff |