Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Writing and maintaining Tk GUIs with ZooZ

by g0n (Priest)
on Jun 03, 2006 at 11:20 UTC ( [id://553419]=note: print w/replies, xml ) Need Help??


in reply to Re: Writing and maintaining Tk GUIs with ZooZ
in thread Writing and maintaining Tk GUIs with ZooZ

What this means is that you can create a part of a GUI with ZooZ, and dump that as a .PM file. The .PM file will contain a Tk mega widget that you can include as:

my $w = $mw->myZooZwidget->pack;

++ to that, several times over. Now, what would be really cool would be to pass an object into the megawidget, and use that for callbacks/variables in the same way as I described in the OP. The Tk::mega constructor doesn't like more than 2 params, but that can be overloaded in the .pm file like this:

my $worker; sub new { my ($class, $mw, $worker) = @_; my $self = $class->SUPER::new($mw); return $self; }

Done this way the callbacks would be acting on $worker, which is in package scope, so don't need to be exported into main::

This would entail changes to dumpPerlPM to declare objects as undef, then construct the my ($class,$mv,..,..,..) = @_ line in new with a list of the objects. From playing with this last night, I don't think the changes I sent you last week write out object attributes to .pm files correctly anyway - I'll take another look at that.

That would allow me to create standard megawidgets associated with my classes, and maybe even in the class, create methods like this:

sub widget { my $self = shift; my $mw = shift; if ($self->{widget}){return $self->{widget}} use autouse 'workerwidget'; my $widget = $mw->workerwidget($self); $self->{widget} = $widget; return $widget; }

(With the autouse just in case I'm using my class on a system with no tk installed). Then, to put (for example) a list of servers with checkboxes in my window, I'd just need to do this:

my $worker = ServerListClass->new(); my $serverlistwidget = $mv->$worker->widget($mw)->pack();

I guess this kind of stuff in general Tk programming terms is probably covered in one of the Tk programming books. Perhaps a trip to the bookshop is called for...

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

"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".

Can you spare 2 minutes to help with my research? If so, please click here

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://553419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 09:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found