Download Padre

Padre Plugin Cookbook Recipe 01

  • This page complements {{{Padre::Plugin::Cookbook Recipe-01}}}, 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 in Attachments.
  • Updated to Padre plug-in API 2.2

Step 1 - Create Skeleton

Padre can do this for you see [wiki:Features/ProjectSkeletonGeneration Project Skeleton Generation]
  • Assumption you are building in your copy of Padre trunk.
    • for me this is, /src/Padre/Padre == {{{}}}
    • thus for me, Cookbook01 is located in /src/Padre/Padre-Plugin-Cookbook01, checkout some other Plugins to see for your self.
  • FBP/fbp directories, follow current Padre trunk Naming convention
├── fbp
│   └── MainFB.fbp
├── lib
│   └── Padre
│       └── Plugin
│           ├── Cookbook01
│           │   ├── FBP
│           │   │   └──
│           │   └──
│           └──
└── t

Step 2 Create MainFB.fbp (xml)

  • Use wxFormBuilder, v3.1.70
  • Create in following order of table below.
  • save to plug-in root /fbp/MainFB.fbp as above.
wxStaticTextm_staticText1Hello Worldn/awxALIGN_CENTERn/an/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

Step 3 {{{Padre::Plugin::FormBuilder}}}

  • Use generator to create from MainFB.fbp
  • Tip have {{{}}} Open before running generator.

Step 4 Perl Plug-in Code

  • Read POD for {{{Padre::Plugin}}}
  • Read POD for and
  • Cookbook01 Required methods with minimum requirements
sub padre_interfaces {
	return (
		# Default, required
		'Padre::Plugin'         => '0.91',
		# used by MainFB by Padre::Plugin::FormBuilder
		'Padre::Wx::Role::Main' => '0.91',
		# used by MainFb by Padre::Plugin::FormBuilder
		'Padre::Wx'             => '0.91',
# Called by Padre::Wx::Dialog::PluginManager
# my @needs = $plugin->padre_interfaces;

sub plugin_name {
	return 'Cookbook01';
# Called by Padre::Wx::Dialog::PluginManager
# $self->{label}->SetLabel( $plugin->plugin_name );

What is Padre::Wx

XS magic
Wx loads it at runtime
when you use Wx;
and when you use Padre::Wx you get Wx::*
basically they are loading symbols on the fly when the C library loads
or shared library (.so)
Thanks for that azawawi.
  • Run Tests, note results, //critiques welcome.

Step 5 Run

  • perl dev -a -die
  • You should now have Cookbook01 in your Tools menu, enjoy.

Foot Notes

Why Main

Well I needed a convention that I could expand upon. Which made sense to me, so here goes:
  • MainFB.fbp is generated by wxFormBuilder,
  • is geneated from previous by {{{Padre::Plugin::FormBuilder}}}.
The FB tells me it's nought to do with me.
  • is the event handler for {{{}}}.
Plugin Dialog