Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: My first pTk megawidget

by choroba (Cardinal)
on Nov 10, 2021 at 21:27 UTC ( [id://11138705]=note: print w/replies, xml ) Need Help??


in reply to Re^4: My first pTk megawidget
in thread My first pTk megawidget

I don't understand. Please describe what happens and how it differs from your expectations. Try to be precise, avoid using "it" after introducing several widgets as it's unclear which one it refers to.

Also, try to post runnable code. I can't find Tk::ListBox3 anywhere.

Moreover, you mentioned an error in the first post. What error was that?

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^6: My first pTk megawidget
by Anonymous Monk on Nov 10, 2021 at 22:06 UTC

    The call to ListBox3 is commented . It is unneeded. I might have fixed the error. When I call the widget I see what I want. When I click on the red "Abort" button, I get a frame that is blanked out. Is this correct? Like I said: Am I interpreting what I see on the screen correctly?

      #!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=1111 +8320 use warnings; # my first pTk-MEGAWIDGET: I develope +d the code. It was widgetized by a "perl monk" use Tk; # THIS THING WORKS!! { # for package package Tk::GUIask; use List::Util qw( first ); use base qw/ Tk::Frame /; # Frame-based composite Construct Tk::Widget 'GUIask'; # install MyNewWidget in pTk namespace sub ClassInit # called once to initialize new class { my($class, $mw) = @_; $class->SUPER::ClassInit($mw); } sub Populate # called to build each widget instanc +e { my($self, $args) = @_; $self->SUPER::Populate($args); my $search = ''; my $frame = $self->Frame( -borderwidth => 5, -relief => 'ridge', )->pack(-fill=> 'both', -expand=> 1); my $label = $frame->Label( -fg => 'black', # 'blue', #-font => 30, )->pack(-fill => 'x'); my $lbox; my $entry = $frame->Entry( -textvariable => \$search, -validate => 'key', # -validatecommand => sub # { # my ($want) = +@_; # length $want +or return 1; # my @list = $l +box->get(0 , "end"); # my $item = fi +rst { $list[$_] =~ /^\Q$want\E/ } 0 .. $#list; # defined $item + or return 0; # $lbox->select +ionClear( 0 , "end" ); # $lbox->select +ionSet($item); # $lbox->see($i +tem); # 1 # to allow # }, )->pack(-fill => 'x'); my $button = $frame -> Button( -text => "Abort", -bg => 'red', -command => sub { #$mw -> destroy(); ($frame -> destroy() ) if Tk::Exists +($frame ); } ) ->pack(-fill => 'x' ); $self->ConfigSpecs( DEFAULT => [$lbox], text => [$label] ); $self->Delegates( Construct => $lbox, insert => $lbox ); } } # CLOSE package my $header_msg = "ENTER Archive name: "; my $mw = MainWindow->new; # $mw->geometry( '+900+250' ); $mw->title( ' ' ## " " must be specified for a plain frame ); my $lb = $mw->GUIask( -text => $header_msg, )->pack(-fill => 'both', -expand => 1, -side => 'left'); MainLoop;

      I LEARNED SOMETHING. The widget was working correctly. I was confused because the top window (in this case $mw) was the same size as the widget GRRRRRR. NOW, how do I get the entered data back? To test what I was doing, I had to use a stripped down GUI from another program I am working on. But to make it display the way I want, I needed to put the widget between: $dialog = $top -> DialogBox ( -title => 'Select Database', -buttons => [] ); . . . $top = $dialog -> Show(); Is there a better way to do this?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-03-29 00:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found