Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Tk::Listbox: 2 questions: performance and alignment

by hiseldl (Priest)
on Oct 10, 2002 at 14:01 UTC ( [id://204179]=note: print w/replies, xml ) Need Help??


in reply to Tk::Listbox: 2 questions: performance and alignment

I'm sure I've read somewhere, that you can somehow freeze a widget while you update it and show it afterwards, but I forgot where and how.

I'm not sure what you mean, do you want to store the data from the ListBox using Storable, for example?

use Storable; tie $hashref, "Tk::Listbox", $lbox, {'ReturnType' => 'both'}; store $hashref, 'file'; ... $hashref = retrieve('file');

Do you want to hide the widget? $listbox->packForget();

Or, do you want to store the configuration of the widget?

use Storable; @columninfo = $mlistbox->columnPackInfo(); store \@columninfo, 'file';

The next question concerns the alignment of the Listbox entries. They are left aligned by default. How can I change this to right or center aligned?

# "-anchor" specifies how the information in a widget (e.g. # text or a bitmap) is to be displayed in the widget. Must # be one of the values n, ne, e, se, s, sw, w, nw, or # center. For example, nw means display the information # such that its top-left corner is at the top-left corner # of the widget. $mlistbox->configure(-anchor => 'e'); # or 'center'

--
hiseldl
What time is it? It's Camel Time!

Replies are listed 'Best First'.
Re: Re: Tk::Listbox: 2 questions: performance and alignment
by busunsl (Vicar) on Oct 11, 2002 at 07:03 UTC
    I'm not sure what you mean, do you want to store the data from the ListBox using Storable, for example?

    No, I didn't mean the freeze/thaw methods.

    Do you want to hide the widget?

    Yes, something like that. But with packForget and pack it's hard to put the widget into the same place. I thought there was another method.

    # "-anchor" specifies how the information in a widget (e.g.
    # text or a bitmap) is to be displayed in the widget.

    I know, but this doesn't work:

    my $MW = MainWindow->new(); $lb = $MW->Listbox()->pack(); $lb->configure(-anchor => 'e');
    Gives just:
    Bad option `-anchor' at yy.pl line 12.
    I also tried -justify without success.

      Is sounds like you need the grid layout manager instead, and the analagous method gridForget. Grid allows you to place everything in cells which gives you a finer level of control over the placement of your widgets.

      Check out this node for an example of how to use the grid layout manager. If you have any questions, leave a note here, or you can /msg hiseldl.

      --
      hiseldl
      What time is it? It's Camel Time!

        Yes, you're right, I can try grid or put the listbox in a frame of its own.

        Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-28 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found