Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: wxPerl: Wx::DatePickerCtrl crashes its sizer?

by Anonymous Monk
on Apr 22, 2013 at 00:13 UTC ( [id://1029791]=note: print w/replies, xml ) Need Help??


in reply to wxPerl: Wx::DatePickerCtrl crashes its sizer?

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)

Replies are listed 'Best First'.
Re^2: wxPerl: Wx::DatePickerCtrl crashes its sizer?
by HelenCr (Monk) on Apr 22, 2013 at 01:14 UTC

    Thank you, AM. I'll study this, and comment.

    Helen

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1029791]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-03-19 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found