# 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_HINT EVT_CLOSE ); use parent -norequire, 'Wx::Frame'; use Wx qw(:id :toolbar :statictext wxNullBitmap wxDefaultPosition wxDefaultSize wxTB_VERTICAL wxSIZE wxDP_ALLOWNONE wxTP_DEFAULT ); sub new { #1 --------------------------- new MyForm:: 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, wxDefaultPosition, 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;