Hi,
Wx::Grid must have an object that derives from Wx::Window as a parent,
usually a Wx::panel or Wx::Frame based object but anything derived from
Wx::Window will work.
You are not passing any type of object as a parent - just the class name
'project_grid'.
The CPAN module Wx::Demo contains several examples of Wx::Grid usage.
Hope it helps.
Mark
On 22/11/2011 20:58, Glendon Solsberry wrote:
I'm using a notebook control to add a tabbed interface to my Wx app.
but when I try to add a grid control to one of the tabs, I get the
error message variable is not an object: it must have type Wx::Window;
what am I doing wrong?
Example code:
my $panel = Wx::Panel->new($self);
# Create the notebook control
my $tabs = Wx::Notebook->new($panel, -1, [0, 40], [300, 150]);
# Create a few pages
my $projects = Wx::Panel->new($tabs);
project_grid->new($projects);
$tabs->AddPage($projects, 'Projects');
package project_grid;
use Wx::Grid;
use Config::Tiny;
sub new {
my $self = shift;
my $ini = Config::Tiny->read("./config.ini");
my $grid = Wx::Grid->new(
$self, #parent
-1, #id
[0,0], #position
[700, 300] #dimensions
);
$grid->CreateGrid(
0, #rows
0 #cols
);
$grid->SetColLabelValue($column++,"Project");
foreach my $project ($ref->{projects}{project}) {
$grid->AppendRows();
$column = 0;
$grid->SetCellValue($row, $column++, $project->{project_name});
$row++;
}