← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] RFC: toolbar button support for action plugins

 

Hi Andrew-

I like the idea.  Aside from minor formatting (headers get 1 space between
function defs, need a space before the if block), the patch looks good.

However, I wouldn't want everything showing on my toolbar (speaking as
someone who has 10 plugins installed, 5 of which get regular use).  I'd
prefer the option to be configurable.  This should probably be in the
preferences pane that Jeff has been re-working.

-Seth

Am Do., 16. Aug. 2018 um 22:11 Uhr schrieb Andrew Lutsenko <
anlutsenko@xxxxxxxxx>:

> Hi Clemens,
>
> See sample plugin attached. Extract it into kicad's
> share/scripting/plugins folder.
> One of other scanned directories that are documented in kicadplugins.i
> <https://github.com/KiCad/kicad-source-mirror/blob/6fdc5972f8431b4d5831a32649e67bfe20d05de8/scripting/kicadplugins.i#L180> should
> work too.
>
> Or are you asking to update docs in the repo?
> Documentation/development/pcbnew-plugins.md seems like the right place.
> I will update it once committers agree with the path I've chosen to
> implement this.
>
>
>
> On Thu, Aug 16, 2018 at 4:48 AM Clemens Koller <cko@xxxxxxxxx> wrote:
>
>> Hello,  Andrew!
>>
>> I am somehow missing the Python example you are giving in your patch.
>> Can you add this a simple example to the sources to get a basic/dummy
>> skeleton working right from scratch?
>>
>> Regards,
>>
>> Clemens
>>
>>
>> On 15/08/2018 11.31, Andrew Lutsenko wrote:
>> > Hi KiCad devs,
>> >
>> > I am proposing an addition to plugin system.
>> > Probably most will agree that menus suck. Toolbars suck less :)
>> >
>> > In my plugin I added a dirty hack to modify top toolbar from plugin
>> init code to add a button
>> > that calls plugins run() method. It is broken on linux X11 and is not a
>> sustainable way others
>> > can add buttons in their plugins. But having a button was quite popular
>> among users so I
>> > decided to implement this functionality directly in pcbnew.
>> >
>> > I introduced one more field plugin writers can define in defaults()
>> that contains path to png icon
>> > and if that string is not empty, pcbnew will attempt to load that icon
>> and add a button to top
>> > toolbar with action that calls the same run() method. I traced in code
>> how plugin action menu
>> > is generated and added similar logic for buttons.
>> >
>> > Here is how the result looks like:
>> >
>> > https://i.imgur.com/f3xg1FE.gif
>> >
>> > Sample dummy plugin __init__.py code:
>> >
>> > import os
>> > import pcbnew
>> > import wx
>> >
>> > class Plugin1(pcbnew.ActionPlugin):
>> >
>> >     def defaults(self):
>> >         self.name <http://self.name> = "Dummy Plugin 1"
>> >         self.category = "Read PCB"
>> >         self.description = ""
>> >         self.icon_file_name = os.path.join(os.path.dirname(__file__),
>> 'icon.png')
>> >
>> >     def Run(self):
>> >         wx.MessageBox("Plugin 1")
>> >
>> > Plugin1().register()
>> >
>> > It's as simple as that.
>> >
>> > The patch is attached. It probably needs some error checking but seems
>> to be working great.
>> > Tested in win64 so far.
>> > I'm open to suggestions on how to get it to good state, I will also
>> test on linux asap.
>> >
>> > Regards,
>> > Andrew
>> >
>> > _______________________________________________
>> > Mailing list: https://launchpad.net/~kicad-developers
>> > Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> > Unsubscribe : https://launchpad.net/~kicad-developers
>> > More help   : https://help.launchpad.net/ListHelp
>> >
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp
>>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References