Friday, February 18, 2011

perl/tk mega-widget configuration

perldoc Tk::ConfigSpec says if where is set to SELF then "apply configure to the core widget" but it doesn't explain how to make it work. I started with a skeleton widget:
package Tk::Test;

use strict;
use warnings;

use base 'Tk::Frame';
Tk::Widget->Construct('Test');

sub ClassInit {
    my ($class,$mw) = @_;
    $class->SUPER::ClassInit($mw);
}

sub Populate {
    my ($self, $args) = @_;

    $self->SUPER::Populate($args);

    $self->ConfigSpecs(
        -xxx    => [ 'SELF', 'xxx', 'Xxx', 'x' ],
    );
}

1;
But when I created one, setting option -xxx, I got the following error:

Tk::Error: Can't set -xxx to `XX' for Tk::Test=HASH(0x93d5420): unknown option "-xxx" at /usr/lib/perl5/Tk/Configure.pm line 47.
Eventually I figured out that I need a configure subroutine in my widget. It gets called after Populate has run, passed the -xxx option and its value. My initial widget was inheriting its configure subroutine from Tk::Frame and that configure didn't accept the -xxx option (and why wouldn't it).

I added a configure subroutine...

package Tk::Test;

use strict;
use warnings;
use Data::Dumper;

use base 'Tk::Frame';
Tk::Widget->Construct('Test');

sub ClassInit {
    my ($class,$mw) = @_;
    $class->SUPER::ClassInit($mw);
}

sub Populate {
    my ($self, $args) = @_;

    $self->SUPER::Populate($args);

    $self->ConfigSpecs(
        -xxx    => [ 'SELF', 'xxx', 'Xxx', 'x' ],
    );
}

sub configure {
    my ($self, @args) = @_;

    print "configure: " . Dumper(\@args);
}

1;
With this, the error was gone. Now all I have to do is learn how to write a configure sub properly.

Wednesday, June 23, 2010

Software Patents in New Zealand

Steve Lundberg does not represent me. He claims to represent the supply side of the New Zealand Information and Communications Technology industry (see the note at the end of http://webcache.googleusercontent.com/search?q=cache:wzDfoNHqC5YJ:www.patents4software.com/%3Fp%3D72) and he advocates for software patents in New Zealand. But I have been writing software for over 30 years and I don't want software patents in New Zealand or anywhere. Steve Lundberg does not represent me.

It is interesting, and I am sure no coincidence, that the U-turn of the New Zealand government on the issue of software patents was leaked by a US based patent lawyer. I suspect Mr Lundberg works for US interests, not the interests of New Zealand. No doubt, those interests he is working for are interested in extracting as much value as they can from New Zealand. He is very pleased with the U-turn, and that is all the more reason for everyone in New Zealand to be very displeased.

Software patents are the tools of large global companies that can afford patent portfolios and legal teams and use them to eliminate competition. They provide little prospect of benefit and great risk of harm to New Zealand (or anywhere or anyone else except for those few mamoth companies that will never have anything but sales offices, lawyers and "tax" collecters here in New Zealand). Consider the absurdity of patents that have been issued in the United States and Europe. Consider the reality of a small company defending a patent and, worse, the reality of a small company defending itself against claims of patent violation. Consider that the largest companies in New Zealand are worth less than lunch for the legal teams of the big players in the software industry.

Even if one admits merit in software patents (I don't, but many do) then they should be rejected on the basis that the cost of mediating and enforcing the privileges granted by patents exceeds the value of what is patented. It is fundamentally unjust that defending oneself against even frivolous claims of patent infringement can bankrupt a person or business. Even if patents do encourage development that benefits society, this benefit must be weighed against the lost benefit of development that is discouraged by the risk of costs associated with defending oneself against claims of patent infringement.

Friday, June 18, 2010

gmusicbrowser on Debian Lenny

I have Debian Lenny on my laptop and I wanted gmusicbrowser. There isn't a package to install this on Lenny, but there is one to install it on sid (http://packages.debian.org/sid/sound/gmusicbrowser) and this package installed without error on lenny and, so far, is running without any problems.

To install it, download the .deb file from the above noted page (follow the "all" link under Architecture in the table at the bottom of the page, pick a mirror and download), then install with:

dpkg -i gmusicbrowser_1.0.2-2_all.deb

This may not be the best way to install it, but it's easy enough and it seems to have worked OK.

Friday, May 21, 2010

Hunt the Wumpus

I started trying to understand how upstart works recently and feel like I'm in a maze of twisty little passages, all alike. The documentation and configuration files provide many disjoint bits of information but there is nothing to knit it all together into an understandable pattern. Figuring out what the connections are between all these little bits is as challenging now and finding the Wumpus was then. And, according to https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/557177, even more dangerous. I know I can read the source, but it really shouldn't be so hard.

I decided to replace Ubuntu with something that doesn't use upstart, but a little research gives the impression that upstart has already been adopted by many of the major distributions and is being considered by many more. It seemed I would have to live in fear of the Wumpus, lost in a maze of twisty little passages, too scared to shoot my crooked little arrows.

Then I came across Lennart Poetterin's blog about systemd: http://0pointer.de/blog/projects/systemd.html. It is refreshingly lucid and leaves me feeling there is hope after all. The concepts are expressed simply, making them understandable. The big picture is presented, providing a context in which the technical details can be understood and related. It feels like a solution and something I would like to work with.

This is in sharp contrast to upstart, which feels like manifold layers of obscure complexity heaped on the problem with little or no hints how it works, except in its parts. The original problem is out of sight and soon forgotten as one struggles to find where all the events come from and go to to knit the bits (jobs) together.

So, bravo to Lennart. I know it is early days for systemd but based on what I have seen I would be very pleased if it supplanted upstart and even the very comfortable old Sys V init scripts.

Monday, October 12, 2009

Brady Harris

I downloaded North Hollywood Skyline from Jamendo and I love it - smooth!

He also has a page on Myspace.

Well worth a listen.

Tuesday, July 21, 2009

Shino

Not the glaze and not one of the anime characters or other people listed on Wikipedia - but the musician.

This is a great album. I love his voice.

I'm a fan.

Saturday, July 18, 2009

Perl's sitecustomize.pl

Perl has an option to run sitecustomize.pl very early and regardless of what program is running.

The Configure option to enable this is -Dusesitecustomize. See the INSTALL documentation that comes with the perl source for a brief description. It is not enabled by default.

See perlrun for a brief description of how to prevent execution of this script, if it has been enabled. This P5P thread describes how it works.

ActiveState perl may have this option enabled. It did, but I don't know if it does currently.

Another option is to create a configuration module and use this module when running perl. For example, if you create CONF.pm you can invoke your program as: perl -MCONF program.pl. Alternatively, you can set the environment variable PERL5OPT to include "-MCONF", but note that this option may be processed too late if you are using other -M options on the command line.

Labels