Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: wxPerl virtual list control not calling OnGetItemText?

by jmlynesjr (Hermit)
on Mar 14, 2013 at 13:18 UTC ( #1023473=note: print w/replies, xml ) Need Help??

in reply to wxPerl virtual list control not calling OnGetItemText?


Here's some working code you can build on. A subclassing of ListCtrl.

#! /home/xxxx/CitrusPerl/perl/bin/perl # wxPerl Virtual list control test # Created by: HelenCR # Last Modified: March 14,2013 by James M. Lynes, Jr. package MyForm; use strict; use warnings; use Wx qw[:everything]; use base 'Wx::Frame'; sub new { my $class = shift; my $self = $class->SUPER::new( undef, -1, 'Phone book', [ 200, 20 +0 ], wxDefaultSize); my $panel = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefault +Size); $self->{list_ctrl} = MyListCtrl->new($panel); my $sizer = Wx::BoxSizer->new(wxVERTICAL); $sizer->Add( $self->{list_ctrl}, 0, wxALL | wxEXPAND, 5 ); $panel->SetSizer($sizer); return $self; } package MyListCtrl; # Subclass ListCtrl to allow use of a Virtual List Control and a custo +m OnGetItemText Subroutine use strict; use warnings; use base qw(Wx::ListCtrl); use Wx qw(:everything); sub new { my( $class, $parent ) = @_; my $self = $class->SUPER::new( $parent, -1, wxDefaultPosition, wxD +efaultSize, wxBORDER_SUNKEN | wxLC_REPORT | wxL +C_VIRTUAL | wxLC_HRULES ); $self->InsertColumn( 0, 'Last Name' ); $self->InsertColumn( 1, 'First Name' ); $self->InsertColumn( 2, 'Addr City' ); $self->InsertColumn( 3, 'Addr State' ); $self->SetItemCount( 1000 ); return $self; } sub OnGetItemText { print "Entered OnGetItemText\n"; my ($line, $column, $data_item); my ($self, $item, $col) = @_; $data_item = 'test'; return $data_item; } my $app = Wx::SimpleApp->new; my $frame = MyForm->new; $frame->Show(1); $app->MainLoop;


There's never enough time to do it right, but always enough time to do it over...

Replies are listed 'Best First'.
Re^2: wxPerl virtual list control not calling OnGetItemText?
by HelenCr (Monk) on Mar 14, 2013 at 17:18 UTC

    Thanks a lot, James. I'm studying it.

    Your code is really helpful and instructive.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1023473]
[1nickt]: The Google-fu is strong with this one.
[1nickt]: I was looking at Best Buy since like the in-store return/repace plan ... but the 17" HP Envy they have is not this one ....
[1nickt]: May be brand new ... 0 reviews on the site.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2017-03-26 18:16 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (315 votes). Check out past polls.