Re: CreateCommand question
[email protected] (Kevin Walzer) Fri, 08 May 2015 07:13:43 -0400
| Newsgroups | perl.tcltk |
|---|---|
| Organization | WordTech Communications LLC |
| Message-ID | <[email protected]> |
On 5/6/15 1:40 PM, Konovalov, Vadim wrote:
>> I am working on a Perl/Tkx app and trying to use the Tcl
>> module's CreateCommand call to feed a Perl subroutine
>> directly to the Tcl interpreter. There is no documentation
>> on how to do this directly from Tkx so I've done a bit of
>> code diving into the module's internals.
>
> use Tkx;
> my $mw = Tkx::widget->new(".");
> $mw->new_button(
> -text => "Hello, world",
> -command => sub { $mw->g_destroy; },
> )->g_pack;
> Tkx::i::interp()->CreateCommand('scriptSetDir', \&scriptSetDir);
> sub scriptSetDir {
> print STDERR '[',(join ',', @_),']';
> return;
> my $dname = shift;
> &selectFileSystem($dname);
> }
> Tkx::eval("scriptSetDir", "/Users/kevin");
> Tkx::MainLoop();
>
This command construction worked best for me:
Tkx::i::interp()
->CreateCommand( "scriptSetDir", \&scriptSetDir, undef, undef, '1' );
Thanks,
Kevin
--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com