HelenCr has asked for the wisdom of the Perl Monks concerning the following question:
Dear esteemed PerlMonks
In an application I'm working on, I am trying to incorporate a Wx::DatePickerCtrl, and a Wx::TimePickerCtrl.
Now the DatePicker control seems to be working fine; the TimePicker control is failing in a strange way.
Your help will be appreciated.
Here are the examples. They are practically identical:
DatePickerCtrl:
# File Name: datepicker example.pl use strict; use warnings; use Wx; use 5.014; use autodie; use Win32::Console; package MyForm; # ------------------------------------------------- +----------------- package MyForm:: use strict; use warnings; use Wx qw[:everything]; # easy when testing use Wx::DateTime; use Wx::Calendar; use Wx qw(:sizer :datepicker :misc); use Wx::Event qw( EVT_DATE_CHANGED EVT_TIME_CHANGED EVT_LIST_CACHE_HIN +T EVT_CLOSE ); use parent -norequire, 'Wx::Frame'; use Wx qw(:id :toolbar :statictext wxNullBitmap wxDefaultPosition wxDe +faultSize wxTB_VERTICAL wxSIZE wxDP_ALLOWNONE wxTP_DEFAULT ); sub new { #1 --------------------------- new My +Form:: my $class = shift; my $self = $class->SUPER::new( undef, -1, # parent window; ID -1 means any 'DatePicker example', # title [80,120], [300,100], ); my ( $date_ctrl, $time_ctrl); my $panel = Wx::Panel->new( # Adding a panel $self, -1, # parent window, ID wxDefaultPosition, [300,100]); $panel->SetBackgroundColour(Wx::Colour->new('light blue')); my $date_from = Wx::DateTime->new; $date_ctrl = Wx::DatePickerCtrl->new( $panel, -1, $date_from, wxDe +faultPosition, wxDefaultSize, wxDP_ALLOWNONE ); my $sizer_main = Wx::BoxSizer->new(wxVERTICAL); $sizer_main -> Add ( $date_ctrl, 0, wxALL | wxEXPAND, 10); $panel->SetSizer($sizer_main); $sizer_main->Fit($panel); $sizer_main->SetSizeHints($panel); $panel->Fit; return $self; } #1 end sub new MyForm:: 1; # end package MyForm package main; # ------------------------------------------- +---------------- package main:: use strict; use warnings; use 5.014; use autodie; use Win32::Console; use English '-no_match_vars'; my $app = Wx::SimpleApp->new; my $frame = MyForm->new; $frame->Show(1); $app->MainLoop; 1;
and here is the TimePickerCtrl example:
# File Name: timepicker example.pl use strict; use warnings; use Wx; use 5.014; use autodie; use Win32::Console; package MyForm; # ------------------------------------------------- +----------------- package MyForm:: use strict; use warnings; use Wx qw[:everything]; # easy when testing use Wx::DateTime; use Wx::Calendar; use Wx qw(:sizer :timepicker :misc); use Wx::Event qw( EVT_DATE_CHANGED EVT_TIME_CHANGED EVT_LIST_CACHE_HIN +T EVT_CLOSE ); use parent -norequire, 'Wx::Frame'; use Wx qw(:id :toolbar :statictext wxNullBitmap wxDefaultPosition wxDe +faultSize wxTB_VERTICAL wxSIZE wxDP_ALLOWNONE wxTP_DEFAULT ); sub new { #1 --------------------------- new My +Form:: my $class = shift; my $self = $class->SUPER::new( undef, -1, # parent window; ID -1 means any 'TimePicker example', # title [80,120], [300,100], ); my ( $date_ctrl, $time_ctrl); my $panel = Wx::Panel->new( # Adding a panel $self, -1, # parent window, ID wxDefaultPosition, [300,100]); $panel->SetBackgroundColour(Wx::Colour->new('light blue')); my $time_from = Wx::DateTime->new; $time_ctrl = Wx::TimePickerCtrl->new( $panel, -1, $time_from, wxDe +faultPosition, wxDefaultSize, ); my $sizer_main = Wx::BoxSizer->new(wxVERTICAL); $sizer_main -> Add ( $time_ctrl, 0, wxALL | wxEXPAND, 10); $panel->SetSizer($sizer_main); $sizer_main->Fit($panel); $sizer_main->SetSizeHints($panel); $panel->Fit; return $self; } #1 end sub new MyForm:: 1; # end package MyForm package main; # ------------------------------------------- +---------------- package main:: use strict; use warnings; use 5.014; use autodie; use Win32::Console; use English '-no_match_vars'; my $app = Wx::SimpleApp->new; my $frame = MyForm->new; $frame->Show(1); $app->MainLoop; 1;
variable is not of type Wx::Point at timepicker example.pl line 34.If I add wxTP_DEFAULT when calling the TimePickerCtrl constructor, namely:
$time_ctrl = Wx::TimePickerCtrl->new( $panel, -1, $time_from, wxDefaultPosition, wxDefaultSize, wxTP_DEFAULT);the script fails now with:
Error while autoloading 'Wx::wxTP_DEFAULT' at timepicker example.pl line 34.What to do?
Many thanks in advance - Helen
NB I am running StrawberryPerl 5.014 on WinXP, $Wx::VERSION = 0.9917
|
---|
Back to
Seekers of Perl Wisdom