Re: treectrl widget
[email protected] (gary sachs) Sat, 17 Sep 2011 01:13:44 -0700 (PDT)
| Newsgroups | perl.tcltk |
|---|---|
| Message-ID | <[email protected]> |
Update...
Here is the PERL code I now have:
$rawtable{$tlabel}->notify_install("<<Edit-begin>>");
$rawtable{$tlabel}->notify_install("<<Edit-end>>");
$rawtable{$tlabel}->notify_install("<<Edit-accept>>");
# List of lists: {column style element ...} specifying elements
# the user can click on or select with the selection rectangle
my $listlist = "";
foreach my $coltag (@taglist)
{
$listlist .= sprintf("%s['%s', 'style1', 'elemRectangle', 'elemText']", (($listlist eq "") ? "" : ","), $coltag);
}
$listlist = "[".$listlist."]";
printf "List of Lists: %s\n", $listlist;
Tkx::TreeCtrl__SetSensitive ($rawtable{$tlabel}, "{COL1 style1 elemRectangle elemText}");
# List of lists: {column style element ...} specifying text elements
# the user can edit
Tkx::TreeCtrl__SetEditable ($rawtable{$tlabel}, "{COL1 style1 elemText}");
# During editing, hide the text and selection-rectangle elements.
$rawtable{$tlabel}->g_bind ("<<Edit-begin>>", [\&begin_edit, Tkx::Ev('%I', '%C'), $rawtable{$tlabel}]);
$rawtable{$tlabel}->g_bind ("<<Edit-accept>>", [\&accept_edit, Tkx::Ev('%I', '%C', '%E', '%t'), $rawtable{$tlabel}]);
$rawtable{$tlabel}->g_bind ("<<Edit-end>>", [\&end_edit, Tkx::Ev('%I', '%C'), $rawtable{$tlabel}]);
#
return 1;
#
} #end of display_rawdata
sub begin_edit
{
my $eitem = shift;
my $ecolumn = shift;
my $ewidget = shift;
#
# example format: $gcanvas{$tabname}{statsheet}->item_element_configure ($itemv, $gcanvas{$tabname}{colids}[$colid], "elemText", -text => $coldata);
#
$ewidget->item_element_configure ($eitem, $ecolumn, "elemText", -draw => 'no');
$ewidget->item_element_configure ($eitem, $ecolumn, "elemRect", -draw => 'no');
#
return 1;
}# end of begin_edit
sub end_edit
{
my $eitem = shift;
my $ecolumn = shift;
my $ewidget = shift;
#
# example format: $gcanvas{$tabname}{statsheet}->item_element_configure ($itemv, $gcanvas{$tabname}{colids}[$colid], "elemText", -text => $coldata);
#
$ewidget->item_element_configure ($eitem, $ecolumn, "elemText", -draw => 'yes');
$ewidget->item_element_configure ($eitem, $ecolumn, "elemRect", -draw => 'yes');
#
return 1;
}#end of end_edit
sub accept_edit #(item col elem txt)
{
foreach (@_){printf "ACCEPT_EDIT Args: %s\n", $_;}
my $eitem = shift;
my $ecolumn = shift;
my $eelement = shift;
my $etext = shift;
my $ewidget = shift;
#
my $curval = $ewidget->item_element_cget ($eitem, $ecolumn, $eelement, "-text");
printf "CURVAL: %s\n", $curval;
if ($etext eq "" || $etext eq $curval) { return 1; }
#
# $self _select $item setname $txt
$ewidget->item_element_configure ($eitem, $ecolumn, $eelement, -text => $etext);
# }
#
return 1;
#
}
Questions:
First from the exanmple of ppm_repolist.tcl what does the command
"$self _select $item setname $txt" do? And thus its PERL equivalent if its really needed?
And it appears that the tcl command "set ::TreeCtrl::Priv(DirCnt,$tree) 0" is the key to enable the actual editing... any advice on what the PERL syntax for this would be?
Again thanks for the support and your patience,
gary
--- On Fri, 9/16/11, vadrer <[email protected]> wrote:
> From: vadrer <[email protected]>
> Subject: Re: treectrl widget
> To: "Jeff Hobbs" <[email protected]>
> Cc: "gary sachs" <[email protected]>, [email protected]
> Date: Friday, September 16, 2011, 4:41 PM
> On Fri, 2011-09-16 at 09:42 -0700,
> Jeff Hobbs wrote:
> > On 15/09/2011 4:36 PM, gary sachs wrote:
> > > Using AS PERL 5.12
> > > TCl 8.5.9
> > > Windows XP SP3
> > >
> > > I have been working with the TREECRTL widget in
> PERL/Tkx for a while now and have good luck. But now I would
> like to be able to set up a table of data for graphing and
> have the ability to edit a "cell" in that table. Does any
> one have a PERL example for TREECTRL showing how to enable a
> "cell" for editting?
> >
> > I don't have a Perl based example, but you can find a
> Tcl example (with
> > necessary bindings and command calls) at
> >
> <AP_Install>/lib/ActivePerl/PPM/tcl/ppm_repolist.tcl.
> Search for 'edit'.
>
> I can cook Tcl::Tk example (rather than Tkx, which is not
> my area of
> expertise)
>
> let me know if this is of any interest.
>
> Regards,
> Vadim.
>
>