Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Insert checkbutton into MListbox

by ghosh123 (Monk)
on Feb 06, 2012 at 09:23 UTC ( [id://952033]=note: print w/replies, xml ) Need Help??


in reply to Re: Insert checkbutton into MListbox
in thread Insert checkbutton into MListbox

Hi , Thanks for your reply. Actually my requirement is to insert some checkbuttons into Listbox or MListbox. There will also be two buttons (up and down) beside the listbox which will let me move up/down any selection in the listbox. Suppose, I have "job" "status" , "time", "result" as checkbuttons in the listbox/mlistbox. I need to select/de-select them (which will happen if they are checkbuttons, no issues) and then by pressing the buttons I can re-order the appearence of checkbuttons in the listbox and finally collect the order of their appearence. That means lets say the above order after pressing up/down on any selection will become "time", "result","job" "status" I have already known MListbox does not support packing widgets in them. Listbox is also not working when I am doing the following thing. I have created a composite widget actually with Listbox and so used Subwidget

my $listbox = $self->Subwidget('listbox'); my $style = $self->ItemStyle('window'); my $btn = $listbox->Checkbutton(-text => 'state'); $listbox->insert('end', [-itemtype => 'window', -widget => $btn, - +style => $style]);

The above code is giving error when I am doing $style = $listbox->ItemStyle('window'). Now I am trying with TList (tix widget). I am able to pack checkbuttons but moving them up and down is not able to do. Please help. Actually, I already have a main window where I have all the above mentioned items as columns. I want to serve a capability to the user of my tool so that they can hide/show columns in that main window and also can change the order of their appearence. For that, I need a dialog which will provide this listbox facility. Upon selection/deselection of checkbuttons and change of their order in the listbox, I will determine which all column to show in the main window and their order as well. You can also suggest any alternative idea, say with NumEntry. But numEntry will set a number to them by which I will get the order the user wants. But what about hide/show then ? I hope I have explained my requirement better. Thanks .

Replies are listed 'Best First'.
Re^3: Insert checkbutton into MListbox
by chessgui (Scribe) on Feb 06, 2012 at 10:49 UTC
    Forget list widgets. Use a Text widget. Pack all the buttons in it that you need. Even add buttons to move items up and down the list (in each row you would have a Checkbutton, an 'UP' Button and a 'DOWN' Button. When the user chooses to move an element a row up or down just create the Text widget from scratch again with the Buttons in the new order and redisplay it.

      Can you please explain the answer a bit more. "Pack all the buttons in it" ... here button means checkbutton ...right ? And you want me to create a 'up' and 'down' button beside each of those checkbuttons in each row ? Currently I am running the following code. If you just look at it,it will help you to explain me a bit elaborately

      #!/usr/bin/perl use strict; use warnings; use Tk; use Tk::TList; use Tk::ItemStyle; my $mw = MainWindow->new(); my $style = $mw->ItemStyle('window'); my $tl = $mw->Scrolled("TList", -scrollbars => "osoe")->pack(-side=>'l +eft', -fill => 'y'); $mw->Button(-text => "UP", -command => \&press_func_up)->pack(); $mw->Button(-text => "DOWN", -command => \&press_func_dwn)->pack(); foreach my $item ("State" , "Dependency", "CalcTime", "Result") { my $btn = $tl->Checkbutton(-text => $item); $tl->insert('end', -itemtype => 'window', -style => $style, -widge +t => $btn); } sub press_func_up { # Move items up } sub press_func_dwn { # Move items up } MainLoop;
        use Tk; my $mw=new MainWindow; my $item_width=15; my %attr_item=('-background'=>'#ffafaf'); my %attr_btn=('-background'=>'#afffaf','-activebackground'=>'#7aaa7a') +; my $text=$mw->Scrolled('Text', -insertontime=>0, -scrollbars=>'e', -width=>($item_width+15), -background=>'#efefef' )->pack; my $first=1; $text->tagConfigure('item',%attr_item); foreach my $item ("State" , "Dependency", "CalcTime", "Result") { my $btn=$text->Checkbutton(%attr_item,'-activebackground'=>'#ff7f7 +f'); my $up=$text->Button(-text=>'Up',%attr_btn); my $down=$text->Button(-text=>'Down',%attr_btn); $text->insert('1.0',"\n") unless $first; $first=0; $text->windowCreate('1.0',-window=>$up); $text->windowCreate('1.0',-window=>$down); $text->windowCreate('1.0',-window=>$btn); $text->insert('1.0',sprintf('%-'.$item_width.'s',$item)); $text->tagAdd('item','1.0',"1.$item_width"); } MainLoop;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found