Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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;
That example runs fine.
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;
This TimePickerCtrl example fails with the message:
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


In reply to wxPerl: Wx::DatePickerCtrl working, Wx::TimePickerCtrl failing? 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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (10)
    As of 2014-11-24 06:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (137 votes), past polls