Esteemed PerlMonks: I hope you can help me with this problem:

I am trying to implement a (trivial) virtual list control demo. It should show a frame, and fill-in all fields with the word: "test".

When I run the program (listed below), it shows the frame and the title, including the scroll bar and the horizontal lines, but it seems that the virtual ListCtrl doesn't call OnGetItemText, so the fields do not get populated.

I'd be very thankful to you if you could help in finding where the error is.

My systems: Strawberry Perl 5.16.0 on Windows XP (same results with DWIM Perl 5.14.2 on Windows 7).

Many TIA - Helen

The program:

# wxPerl Virtual list control test use strict; use warnings; use warnings qw< FATAL utf8 >; use Wx; use Encode; use 5.014; use utf8; use autodie; use Carp; use Carp qw {cluck}; use Carp::Always; use Win32::Console; use English '-no_match_vars'; package MyForm; use strict; use warnings; use Wx qw[:everything]; use base 'Wx::Frame'; sub new { #1 my $class = shift; my $self = $class->SUPER::new( undef, # parent window -1, # ID -1 means any 'Phone book', # title [ 200, 200 ], # position [ 400, 500 ], # size ); # Add a panel my $panel = Wx::Panel->new( $self, # parent window -1, # ID ); $self->{list_ctrl} = Wx::ListCtrl->new( $panel, -1, # ID [ 20, 30 ], # position [ 350, 300 ], # size 32 | Wx::wxBORDER_SUNKEN | Wx::wxLC_VIRTUAL | Wx::wxLC_HRULES, + # window style ); $self->{list_ctrl}->InsertColumn( 0, 'Last Name' ); $self->{list_ctrl}->InsertColumn( 1, 'First Name' ); $self->{list_ctrl}->InsertColumn( 2, 'Addr City' ); $self->{list_ctrl}->InsertColumn( 3, 'Addr State' ); my $sizer = Wx::BoxSizer->new(wxVERTICAL); $sizer->Add( $self->{list_ctrl}, 0, wxALL | wxEXPAND, 5 ); $panel->SetSizer($sizer); $self->{list_ctrl}->SetItemCount(1000); return $self; } #1 end sub new sub OnGetItemText { #1 MyForm:: say 'Entered OnGetItemText'; my ($line, $column, $data_item); my ($self, $item, $col) = @_; $data_item = 'test'; return $data_item; } #1 end sub OnGetItemText MyForm:: # end package MyForm binmode(STDOUT, ":unix:utf8"); binmode $DB::OUT, ':unix:utf8' if $DB::OUT; # for the debugger my $app = Wx::SimpleApp->new; my $frame = MyForm->new; $frame->Show(1); $app->MainLoop;

Note: trying to cross-post here: http://old.nabble.com/wxPerl-virtual-list-control-not-calling-OnGetItemText--tt35170291.html


In reply to wxPerl virtual list control not calling OnGetItemText? by HelenCr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.