momo33 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perlmonks

I'm in the process of converting a Perl/Tk app to a Tkx version.
This turns out to be a bit harder than I hoped.
Some of you monks already solved a few problems,
but I ran into new ones.

The code had a tree, but I was noticed that tree has a bug. Turned to listbox instead.
The code attached shows a frame with a button and a listbox. However:
1- removed, tree bug
2- I want to see the list-item (the text-part) when I click on it, not the index
3- And I want to set the background color of the button and the frame (independently)
Can anyone help me? Thank you!
#!/usr/bin/perl -- use strict; use warnings; use Tkx; $Tkx::TRACE = 64; Tkx::package_require('tile'); use Tkx; my $mw = Tkx::widget->new("."); my $f_report_period = $mw->new_ttk__labelframe( -text => "report period", -labelanchor => 'nw', -relief => 'groove', -borderwidth => '5' ); my $listview = $f_report_period->new_tk__listbox( -height => 5, ); $listview->insert( "end", "T $_ and a very long text to come after that" ) for 1 .. 20; my $tree_sbv = $f_report_period->new_ttk__scrollbar( -command => [ $listview, "yview" ], -orient => "vertical" ); my $tree_sbh = $f_report_period->new_ttk__scrollbar( -command => [ $listview, "xview" ], -orient => "horizontal" ); $listview->configure( -yscrollcommand => [ $tree_sbv, "set" ] ); $listview->configure( -xscrollcommand => [ $tree_sbh, "set" ] ); $listview->g_bind("<1>" , sub{&showline}); sub showline { my @item = $listview->curselection; if ($#item==0) { print "$item[0] \n"; } } $f_report_period->g_grid( -row => 1, -column => 0, -rowspan => 2, -sticky => 'nsew' ); $b_change_year->g_grid( -row => 0, -column => 0, -columnspan => 2, -sticky => 'nsew', ); $listview->g_grid( -row => 1, -column => 0, -rowspan => 1, -sticky => 'nsew' ); $tree_sbv->g_grid( -row => 1, -column => 1, -sticky => 'ns' ); $tree_sbh->g_grid( -row => 2, -column => 0, -sticky => 'we' ); Tkx::MainLoop();

Replies are listed 'Best First'.
Re: several tkx questions
by Anonymous Monk on Jul 07, 2009 at 14:23 UTC
    1- The horizontal scrollbar does not activate

    Seems to be a bug

    I don't recommend using ttk::treeview unless you know in advance that the tree items will not require more horizontal space than the assigned column width.
      That solves one problem. Listbox is the way to go for me, since it is more powerful than the Tk listbox.
        I also need some help. I am in desperate need of a Tkx equivalent of the Tk "Scrolled" object, as I am converting a program that used the old Perl/Tk library. Basically I need something where scrollbars allow me view a larger collection of widgets than I can otherwise -- an actual scrollable frame. The current Tkx examples I have seen so far have only worked for attaching scrollbars to text,canvas,tree, or list. Here is the code I wish to revise up to Tkx:
        $data_pane = $mw->Scrolled(Pane, Name => 'Data', -scrollbars => 'osoe', -sticky => 'n', -width => $mw_min_width, );
        I hope you guys can help me. Information of this sort on the Tkx library has been sparse. I've already checked ActiveState and Tkdocs to no avail. Thanks a ton in advance for helping me crack this problem.