| Version 11 (modified by bowtie, 2 years ago) (diff) |
|---|
Padre::Plugin::Cookbook Recipe-02
- This page complements Padre::Plugin::Cookbook Recipe-02, it is not meant to be installable, just an aid, with a suggested layout, enjoy. More detail will follow in subsequent Cookbooks.
- You can either svn Padre::Plugin::Cookbook or build your own with Cookbook02.zip in Attachments.
Step 1 - Create Skeleton
Padre can do this for you see Project Skeleton Generation
- Assumption you are building in your copy of Padre trunk.
Padre-Plugin-Cookbook02/ ├── fbp │ └── MainFB.fbp ├── lib │ └── Padre │ └── Plugin │ ├── Cookbook02 │ │ ├── FBP │ │ │ └── MainFB.pm │ │ └── Main.pm │ └── Cookbook02.pm └── t
Step 2 Create MainFB.fbp (xml)
- Use wxFormBuilder, v3.1.70
- The table only shows the flow, not indentation, view file MainFB.fbp in wxFormBuilder for that.
- fgSizer1 plays table tennis, RadioBox support added by Alias, much more elegant.
| wxWidget | Properties | Events | |||||
|---|---|---|---|---|---|---|---|
| Icon | Type | name | label/title | public | other | type | value |
Project | Cookbook02 | n/a | n/a | n/a | n/a | n/a | |
Dialog | Padre::Plugin::Cookbook02::FBP::MainFB | Main | n/a | wxRESIZE_BORDER | n/a | n/a | |
wxBoxSizer | bSizer1 | n/a | n/a | n/a | n/a | n/a | |
wxBoxSizer | bSizer2 | n/a | n/a | proportion = 0 | n/a | n/a | |
wxStaticText | heading | heading is public | public | proportion = 0 | n/a | n/a | |
wxStaticLine | m_staticline1 | n/a | n/a | n/a | n/a | n/a | |
wxFlexGridSizer | fgSizer1 | n/a | n/a | n/a | n/a | n/a | |
wxCheckBox | ttennis | TTennis | public | !checked | OnCheckBox | ttennis_checked | |
wxCheckBox | ping | ping | public | !checked !enabled | OnCheckBox | ping_checked | |
spacer | n/a | n/a | n/a | n/a | n/a | n/a | |
wxCheckBox | pong | pong | public | !checked !enabled | OnCheckBox | pong_checked | |
wxStaticText | m_staticText2 | n/a | n/a | Static Text\nPadre Config DB\nuser defined\nattributes | n/a | n/a | |
wxRadioBox | user_name | User * Name | public | proportion = 0 choices = "nick" "cpan" "e-mail" | n/a | n/a | |
wxStaticLine | m_staticline2 | n/a | n/a | n/a | n/a | n/a | |
wxBoxSizer | bSizer3 | n/a | n/a | proportion = 0 wxHORIZONTAL | n/a | n/a | |
wxStaticText | name_label | name_label public | public | proportion = 0 | n/a | n/a | |
wxTextCtrl | name_value | m/t | public | n/a | n/a | n/a | |
wxStaticLine | m_staticline3 | n/a | n/a | n/a | n/a | n/a | |
wxFlexGridSizer | fgSizer2 | n/a | n/a | proportion = 0 | n/a | n/a | |
wxStaticText | m_staticText4 |
| n/a | proportion = 0 | n/a | n/a | |
wxChoice | choice | "CPL" "CPL" "BCPL" "B" "C" "PL" | public | proportion = 0 | n/a | n/a | |
wxStaticLine | m_staticline4 | n/a | n/a | n/a | n/a | n/a | |
wxBoxSizer | bSizer4 | n/a | n/a | proportion = 0 wxHORIZONTAL | n/a | n/a | |
wxButton | output | Output | n/a | n/a | OnButonClick | output_clicked | |
wxButton | update | Update | n/a | n/a | OnButonClick | update_clicked | |
wxButton | close | Close | n/a | Default wxID_CANCEL | n/a | n/a | |
- Dialog must start with Padre::Plugin for Step 3 to work.
- A Sizer is compulsory to hold our text.
- wxRESIZE_BORDER lets you grab lower left hand corner.
- wxALIGN_CENTER centers text
- proportion = 0, to prevent stretching.
Step 3 Padre::Plugin::FormBuilder
- Use generator to create MainFB.pm from MainFB.fbp
- Tip have Padre::Plugin::Cookbook02.pm Open before running generator.
Step 4 Perl Plug-in Code
- Read POD for Padre::Plugin
- Read POD for Cookbook02.pm and Main.pm
- Run Tests, note results, critiques welcome.
output
- To use Padre Output window, to talk to our users, or we could just say to terminal :)
- Open Padre Output window:
$main->show_output(1);
- Create a variable:
my $output = $main->output;
- Clear the Padre Output window.
$output->clear;
- Write to Padre Output window
$output->AppendText("output cliked \n");
Step 5 Run
- perl dev -a -die
- You should now have Cookbook02 in your Tools menu, enjoy.
Foot Notes
- YOU MUST REFERENCE this: wxAlphabetical class reference http://docs.wxwidgets.org/stable/wx_classref.html
- Tip wxStaticText has method SetLabel
public attributes
- The use of public causes Padre::Plugin::FormBuilder to generate an attribute for you.
sub heading { Wx::Window::FindWindowById($_[0]->{heading}); }
- which enables you to manipulate is value.
- code snip from Padre::Plugin::Cookbook02::Main::update_clicked
$self->heading->SetLabel('I am in Control');
events handlers
- The use of OnButonClick causes Padre::Plugin::FormBuilder to generate an empty event method for you (required method).
sub update_clicked { $_[0]->main->error('Handler method update_clicked for event update.OnButtonClick not implemented'); }
- which enables you to perform an action based on a user input.
- code snip from Padre::Plugin::Cookbook02, you must create your own event handler.
sub update_clicked { .... }
Snippets from Padre::Plugin::Cookbook02::Main
__END__
Attachments
-
wxproject.png
(842 bytes) -
added by bowtie 2 years ago.
wxWidget project
-
wxdialog.png
(811 bytes) -
added by bowtie 2 years ago.
wxWidget dialog
-
wxbsizer.png
(229 bytes) -
added by bowtie 2 years ago.
wxWidget bsizer
-
wxflex_grid_sizer.png
(237 bytes) -
added by bowtie 2 years ago.
wxWidget flex_grid_sizer
-
wxbutton.png
(344 bytes) -
added by bowtie 2 years ago.
wxWidget button
-
wxstatic_line.png
(184 bytes) -
added by bowtie 2 years ago.
wxWidget static_line
-
wxstatic_text.png
(195 bytes) -
added by bowtie 2 years ago.
wxWidget static_text
-
wxcheckbox.png
(337 bytes) -
added by bowtie 2 years ago.
wxWidget checkbox
-
wxspacer.png
(233 bytes) -
added by bowtie 2 years ago.
wxWidget spacer
-
wxradio_box.png
(642 bytes) -
added by bowtie 2 years ago.
wxWidget radio_box
-
wxtext_ctrl.png
(323 bytes) -
added by bowtie 2 years ago.
wxWidget text_ctrl
-
wxchoice.png
(380 bytes) -
added by bowtie 2 years ago.
wxWidget choice
-
Cookbook02.zip
(14.8 KB) -
added by bowtie 22 months ago.
updated to Padre v0.90












