I'd still say that wxPerl (and wxWidgets) are not forgiving - it's not for newbies. If you don't know what you're doing, you'll quickly get lost. BTW, comments for improvement of style and quality are welcome.

The two are not unrelated. Naming your variables mainsizer,sizer1,sizer2,button1... is not the best way to keep track of what's what, or what goes where, its easy to get confused

One way of keeping track (what goes where) is naming your sizer/container elements by position, and incorporating the parent/child relationship into the name. Afterwards you incorporate your action elements (text/buttons) and name then by purpose/property/action (email_input/email_text,submit_button,cancel_button... )

Working incrementally on sub problems also helps , like separating the general layout from the rest of your program (in a separate file). Here is an example, generated with wxglade

#!/usr/bin/perl -w -- # generated by wxGlade 0.6.5 (standalone edition) on Sun Apr 21 16:37: +22 2013 # To get wxPerl visit http://wxPerl.sourceforge.net/ use Wx 0.15 qw[:allclasses]; use strict; package MyFrame; use Wx qw[:everything]; use base qw(Wx::Frame); use strict; sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_ +; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; # begin wxGlade: MyFrame::new $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $sty +le, $name ); $self->{splitter_dad} = Wx::SplitterWindow->new($self, -1, wxDefau +ltPosition, wxDefaultSize, wxSP_3D|wxSP_BORDER); $self->{dad_right_pane} = Wx::Panel->new($self->{splitter_dad}, -1 +, wxDefaultPosition, wxDefaultSize, ); $self->{splitter_right} = Wx::SplitterWindow->new($self->{dad_righ +t_pane}, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_BORDER); $self->{low_right_pane} = Wx::Panel->new($self->{splitter_right}, +-1, wxDefaultPosition, wxDefaultSize, ); $self->{top_right_pane} = Wx::Panel->new($self->{splitter_right}, +-1, wxDefaultPosition, wxDefaultSize, ); $self->{dad_left_pane} = Wx::Panel->new($self->{splitter_dad}, -1, + wxDefaultPosition, wxDefaultSize, ); $self->{splitter_left} = Wx::SplitterWindow->new($self->{dad_left_ +pane}, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_BORDER); $self->{low_left_pane} = Wx::Panel->new($self->{splitter_left}, -1 +, wxDefaultPosition, wxDefaultSize, ); $self->{top_left_pane} = Wx::Panel->new($self->{splitter_left}, -1 +, wxDefaultPosition, wxDefaultSize, ); $self->__set_properties(); $self->__do_layout(); # end wxGlade return $self; } sub __set_properties { my $self = shift; # begin wxGlade: MyFrame::__set_properties $self->SetTitle("myframe is sturdy"); $self->{splitter_left}->SetMinimumPaneSize(40); $self->{splitter_right}->SetMinimumPaneSize(40); $self->{splitter_dad}->SetMinimumPaneSize(40); # end wxGlade } sub __do_layout { my $self = shift; # begin wxGlade: MyFrame::__do_layout $self->{frame_sizer} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_dad_right_pane} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_low_right_pane} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_top_right_pane} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_dad_left_pane} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_low_left_pane} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_top_left_pane} = Wx::BoxSizer->new(wxVERTICAL); $self->{top_left_pane}->SetSizer($self->{sizer_top_left_pane}); $self->{low_left_pane}->SetSizer($self->{sizer_low_left_pane}); $self->{splitter_left}->SplitHorizontally($self->{top_left_pane}, +$self->{low_left_pane}, ); $self->{sizer_dad_left_pane}->Add($self->{splitter_left}, 1, wxEXP +AND, 0); $self->{dad_left_pane}->SetSizer($self->{sizer_dad_left_pane}); $self->{top_right_pane}->SetSizer($self->{sizer_top_right_pane}); $self->{low_right_pane}->SetSizer($self->{sizer_low_right_pane}); $self->{splitter_right}->SplitHorizontally($self->{top_right_pane} +, $self->{low_right_pane}, ); $self->{sizer_dad_right_pane}->Add($self->{splitter_right}, 1, wxE +XPAND, 0); $self->{dad_right_pane}->SetSizer($self->{sizer_dad_right_pane}); $self->{splitter_dad}->SplitVertically($self->{dad_left_pane}, $se +lf->{dad_right_pane}, ); $self->{frame_sizer}->Add($self->{splitter_dad}, 1, wxEXPAND, 0); $self->SetSizer($self->{frame_sizer}); $self->{frame_sizer}->Fit($self); $self->Layout(); # end wxGlade } # end of class MyFrame 1; package MyApp; use base qw(Wx::App); use strict; sub OnInit { my( $self ) = shift; Wx::InitAllImageHandlers(); my $frame = MyFrame->new(); $self->SetTopWindow($frame); $frame->Show(1); return 1; } # end of class MyApp package main; unless(caller){ my $app = MyApp->new(); $app->MainLoop(); }
wxglade gui builder shows the parent/child relationships with a treectrl:), here's the corresponding wxg (wxglade xml)

In reply to Re: wxPerl: Wx::DatePickerCtrl crashes its sizer? by Anonymous Monk
in thread wxPerl: Wx::DatePickerCtrl crashes its sizer? 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.