For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > June 2006 > Tie::Tk-Listbox w/ ListboxDnd ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tie::Tk-Listbox w/ ListboxDnd ?
rgarton

2006-05-21, 4:00 am

Tried putting the two together. Tk-Listbox croaks that it can't find
'listbox' from ListboxDnd, derived from the standard Listbox. What am I
missing, please? The offended piece of code from Tk-Listbox is this:

unless (ref $listbox eq 'Tk::Listbox') {
$listbox = $listbox->Subwidget('listbox');
croak "Trouble finding listbox." if not defined $listbox;
}

Rod

Ch Lamprecht

2006-05-21, 4:00 am

rgarton wrote:
> Tried putting the two together. Tk-Listbox croaks that it can't find
> 'listbox' from ListboxDnd, derived from the standard Listbox. What am I
> missing, please? The offended piece of code from Tk-Listbox is this:
>
> unless (ref $listbox eq 'Tk::Listbox') {
> $listbox = $listbox->Subwidget('listbox');
> croak "Trouble finding listbox." if not defined $listbox;
> }
>
> Rod
>

Hi,

the code you show is from Tie::Tk::Listbox. It will obviously fail with
widgets derived from Tk::Listbox. (I think it should use UNIVERSAL::isa
instead of comparing to a literal classname).
Are you sure you need Tie::Tk::Listbox? In Tk 8.027 Tk::Listbox
implements a tied- interface already.

HTH,
Christoph

--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
rgarton

2006-06-06, 4:01 am

The Tk::Listbox tied-interface doesn't work with ListboxDnD. The list
disappears as soon as you try to do any "drag and drop". You might even
get a "Bizarre hash" message. I am unable to translate your
"UNIVERSAL::isa" suggestion.


Ch Lamprecht wrote:

> rgarton wrote:
> Hi,
>
> the code you show is from Tie::Tk::Listbox. It will obviously fail with
> widgets derived from Tk::Listbox. (I think it should use UNIVERSAL::isa
> instead of comparing to a literal classname).
> Are you sure you need Tie::Tk::Listbox? In Tk 8.027 Tk::Listbox
> implements a tied- interface already.
>
> HTH,
> Christoph
>
> --
>
> perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"


rgarton

2006-06-06, 4:01 am

Herein the problem if you'd like to survey it
-------------------

use Tk;
use Tk::ListboxDnD;

my @list = (qw/drag drop blow stink/);

my $mw = MainWindow->new;

$mw->ListboxDnD(
-listvariable => \@list,
-height => 5,
)->pack();


MainLoop;

-----------------------

Ch Lamprecht

2006-06-06, 4:01 am

rgarton wrote:
> Herein the problem if you'd like to survey it
> -------------------
>
> use Tk;
> use Tk::ListboxDnD;
>
> my @list = (qw/drag drop blow stink/);
>
> my $mw = MainWindow->new;
>
> $mw->ListboxDnD(
> -listvariable => \@list,
> -height => 5,
> )->pack();
>
>
> MainLoop;
>
> -----------------------
>

Hi,
Tk::Listbox implements a tied interface.
So as ListboxDnD is a subclass of Listbox
that works with ListboxDnD as well:

use warnings;
use strict;
use Tk;
use Tk::ListboxDnD;

my $mw = MainWindow->new;

my $lb = $mw->ListboxDnD(
-height => 5,
)->pack();

my @list;
tie @list , 'Tk::Listbox' , $lb;

@list = (qw/drag drop blow stink/);

MainLoop;



Christoph
--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
rgarton

2006-06-17, 8:14 am

thankyou CL, that takes care of it nicely

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com