James: I tried to translate and run your example. As you can see from the program here, it lets you set/change the font of a ListCtrl item, but not the headers (tried a couple of approaches).
(Unless I'm doing something wrong). (Although, interestingly, (as you can see by pressing the buttons), it does let you change the header text. But no font or color).
It's a pity, since, if your approach worked, I wouldn't need to start wrestling with Wx::Grid.

# Change header 2.pl: following James: http://www.perlmonks.org/?node_ +id=1025552 use strict; use warnings; use Wx; use 5.014; use autodie; use Carp; use Carp qw {cluck}; use Carp::Always; package MyFrame; use Wx ':everything'; use Wx ':listctrl'; use Wx::Event 'EVT_BUTTON'; use parent -norequire, 'Wx::Frame'; sub new { #1 MyFrame:: my ($class, $parent, $title) = @_; my $self = $class->SUPER::new( $parent, -1, # parent window; ID -1 means any $title, # title [150, 150 ], # position [ 350, 400 ], # size ); my $panel = Wx::Panel->new($self); my $itemCol = Wx::ListItem->new; $itemCol->SetText('Column 1'); my $f = Wx::Font->new(12, -1, wxNORMAL, wxBOLD, 0, 'Arial'); $itemCol->SetFont($f); $self->{list_control} = Wx::ListCtrl->new($panel, -1, wxDefaultPosition, [ +320,100], wxLC_REPORT); # create a list control $self->{list_control}->InsertColumn(0, $itemCol); $self->{list_control}->SetColumnWidth(0, 100); $itemCol->SetText('Column 2'); $self->{list_control}->InsertColumn(1, $itemCol); $self->{list_control}->SetColumnWidth(1, 100); $itemCol->SetText('Column 3'); $self->{list_control}->InsertColumn(2, $itemCol); $self->{list_control}->SetColumnWidth(2, 100); $self->{list_control}->InsertStringItem( 0, 'Data 1' ); $self->{list_control}->SetItem( 0, 1, 'Data 3'); $self->{list_control}->InsertStringItem( 1, 'Data 2' ); $self->{list_control}->SetItem( 1, 1, 'Data 4'); my $btn_header = Wx::Button->new($panel, -1, 'Change header', +wxDefaultPosition, wxDefaultSize); my $btn_item = Wx::Button->new($panel, -1, 'Change item font', + wxDefaultPosition, wxDefaultSize); my $btn_header2 = Wx::Button->new($panel, -1, 'Change header2 +font', wxDefaultPosition, wxDefaultSize); EVT_BUTTON ($self, $btn_header, sub { $self->{list_control}->M +yFrame::on_header }); EVT_BUTTON ($self, $btn_item, sub { $self->{list_control}->MyF +rame::on_item }); EVT_BUTTON ($self, $btn_header2, sub { $self->{list_control}-> +MyFrame::on_item }); my $sizer = Wx::BoxSizer->new(wxVERTICAL); $sizer->Add($self->{list_control}, 0, wxALL, 10); $sizer->Add($btn_header, 0, wxALL, 10); $sizer->Add($btn_item, 0, wxALL, 10); $sizer->Add($btn_header2, 0, wxALL, 10); $panel->SetSizer($sizer); $panel->Layout(); return $self; } #1 end sub new MyFrame:: sub on_header { my $this = shift; say 'In on_header'; my $column = $this->GetColumn(1); say '$column->GetText =', $column->GetText; $column->SetMask(wxLIST_MASK_TEXT); $column->SetText('NEW TITLE'); my $f = Wx::Font->new(12, -1, wxNORMAL, wxBOLD, 0, 'times new +roman'); $column->SetFont($f); $this->SetColumn(1, $column); } #1 end sub on_header sub on_item { my $this = shift; say 'In on_item'; my $item = $this->GetItem(1); my $f = Wx::Font->new(12, -1, wxNORMAL, wxBOLD, 0, 'times new +roman'); say "In on_item, \$this= $this, \$item = $item, \$f= $f"; $item->SetFont($f); $this->SetItem($item); } #1 end sub on_item sub on_header2 { my $this = shift; say 'In on_header2'; my $itemCol = Wx::ListItem->new; $itemCol->SetText('Column 2'); my $f = Wx::Font->new(12, -1, wxNORMAL, wxBOLD, 0, 'Arial'); $itemCol->SetFont($f); $this->SetColumn(1, $itemCol); } #1 end sub on_header2 # end package MyFrame:: package main; my $frame = MyFrame->new(undef, 'Setting headers'); $frame->Show(1); my $app = Wx::SimpleApp->new; $app->MainLoop; 1;

In the meantime, Anonymous Monk has provided another example based on your snippet - it's impressive to see DWIM in action.

Many thanks - Helen


In reply to Re^2: Wx::Perl: How to change/set font and size of Wx::ListCtrl column headings? by HelenCr
in thread Wx::Perl: How to change/set font and size of Wx::ListCtrl column headings? 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.