Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-19 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found