Как удалить пунктирную линию выделения в Tk::HList?

когда запись в Tk::HList выбирается одним щелчком мыши, вокруг этой записи рисуется пунктирная линия. Я не хочу иметь эту линию. Как я могу настроить его? Я не вижу никакого документированного способа сделать это.

Вот пример кода, показывающий Tk::HList с предварительно выбранной записью. При нажатии на запись появится пунктирная линия.

#!perl

use strict;
use warnings;
use utf8;
use Tk;
use Tk::HList;

my $mw = tkinit();

# -- create a Tk::HList
my $scrolled_hlist = $mw->Scrolled('HList',
    -scrollbars => 'se',
    -columns => 2,
    -header => 1,
    -width => 50,
    -height => 20,
    # hide black border around HList when it's active
    -highlightthickness => 0,
    -selectborderwidth => 1,
    -selectmode => 'single',

)->pack(-fill => 'y', -expand => 1,);

my $real_hlist = $scrolled_hlist->Subwidget('scrolled');


# -- add HList header colums
$real_hlist->header(
    'create', 0,
    -text   => 'first column',
);

$real_hlist->header(
    'create', 1,
    -text   => 'second column',
);


# -- add some entries to the HList
$real_hlist->add(1);
$real_hlist->item('create', 1, 0, -text => 'first row, 1st col');
$real_hlist->item('create', 1, 1, -text => 'first row, 2nd col');

$real_hlist->add(2);
$real_hlist->item('create', 2, 0, -text => '2nd row, 1st col');
$real_hlist->item('create', 2, 1, -text => 'second row, 2nd col');


# -- set selection *** without dashed line border ***
$real_hlist->selectionSet(2);

$mw->MainLoop();
exit(0);

person capfan    schedule 17.09.2012    source источник


Ответы (1)


Чтобы найти его, потребовалось некоторое время, но решение состоит в том, чтобы вызвать anchorClear() какbrowsecmd:

#!perl

use strict;
use warnings;
use utf8;
use Tk;
use Tk::HList;

my $mw = tkinit();

# -- create a Tk::HList
my $scrolled_hlist = $mw->Scrolled('HList',
    -scrollbars => 'se',
    -columns => 2,
    -header => 1,
    -width => 50,
    -height => 20,
    # hide black border around HList when it's active
    -highlightthickness => 0,
    -selectborderwidth => 1,
    -selectmode => 'single',
)->pack(-fill => 'y', -expand => 1,);

my $real_hlist = $scrolled_hlist->Subwidget('scrolled');
$real_hlist->configure(
    -browsecmd => [ sub{ $_[0]->anchorClear(); }, $real_hlist],
);

# -- add HList header colums
$real_hlist->header(
    'create', 0,
    -text   => 'first column',
);

$real_hlist->header(
    'create', 1,
    -text   => 'second column',
);


# -- add some entries to the HList
$real_hlist->add(1);
$real_hlist->item('create', 1, 0, -text => 'first row, 1st col');
$real_hlist->item('create', 1, 1, -text => 'first row, 2nd col');

$real_hlist->add(2);
$real_hlist->item('create', 2, 0, -text => '2nd row, 1st col');
$real_hlist->item('create', 2, 1, -text => 'second row, 2nd col');


# -- set selection *** without dashed line border ***
$real_hlist->selectionSet(2);

$mw->MainLoop();
exit(0);

Источник: https://groups.google.com/d/topic/comp.lang.perl.tk/iCE7ql2Bw4E/discussion

person capfan    schedule 18.09.2012