Autrijus Tang wrote:
On Tue, Mar 25, 2003 at 10:23:44PM +0100, Perl Authors Upload Server wrote:
   Working with Tk::Listbox today, it bothered me that I could not
   access the listbox items more easily. Hence I created a tied wrapper
   to access the data in a Tk::Listbox widget.

Nice idea.

Thanks. :) This: $widgets{listbox1}->delete(5,$widgets{listbox1}->index('end')-1); $widgets{listbox1}->insert('end', 1..10);

just didn't have the warm feeling of

splice @listbox, 5, @listbox-5, 1..10;

or possibly

splice @listbox, 5;
push @listbox, 1..10;

or even just

@listbox[5..14] = (1..10);

   It is possible to tie arrays to Tk::Scrolled widgets (and others)
   as well.

This statements suggests that, rather than creating any number of Tie::TkFoo modules, maybe we should organized them into the Tie::Tk
namespace:


        Tie::Tk::Listbox
        Tie::Tk::Scrolled
        ...

This way it is clear that Tie::Tk::* corresponds to the Tk::* namespace,
so we can list them under the UI chapter without introducing much confusion.

Does that sound reasonable to you?

Yes and no. The namespace Tie::Tk::Listbox sounds okay, it's just that you may actually tie Tk::Scrolled and other widgets to Tie::TkListbox arrays because the TIEARRAY method checks whether one of the following situations exist:
a) The passed widget is a Tk::Listbox. Then, the tied object will just be a blessed reference to the passed widget.
b) The passed widget is not a Tk::Listbox but a widget that advertises a Tk::Listbox subwidget. In that case, the subwidget is extracted and a reference to the Tk::Listbox *subwidget* is blessed as the tied object.


This is explained in the Caveats section of the docs. I actually consider this kind of DWIM-ery a feature because using tied() on a tied variable (unless absolutely necessary) is bad style - especially considering that you have keep track of the source widget anyway.

So it's not too smart to split this particular functionality up into multiple tie::tk::* namespaces. It is, however, a good idea to group Tk-related Tie:: module into one second-level namespace.

Maybe a wholly different name would make more sense then, but I can't think of anything better than ::Listbox, so I'll change to the suggested Tie::Tk::Listbox unless I hear from you again within the next few days.

I'll reregister once I switched namespaces.

Steffen
--
@n=([283488072,6076],[2105905181,8583184],[1823729722,9282996],[281232,
1312416],[1823790605,791604],[2104676663,884944]);$b=6;@c=' -/\_|'=~/./g
;for(@n){for$n(@$_){map{$h=int$n/$b**$_;$n-=$b**$_*$h;[EMAIL PROTECTED]
0..11;[EMAIL PROTECTED],[EMAIL PROTECTED];[EMAIL PROTECTED]"\n"[EMAIL PROTECTED];



Reply via email to