Python code to integrate with Layer Manager?

I’m trying to integrate with the Layer Manager (see LayerViewSet). I’ve almost got it but still seeing some problems.

The dock doesn’t seem to work regardless of which AuiManagers.
It does appear to dock, but the LayerManager tabs don’t move out
of the way to reveal the new window behind them (when I manually dock).

def makedock():
    win = wx.FindWindowByLabel('F.Cu')
    am = [wx.aui.AuiManager.GetManager(win)]
    # an attempt to get the AuiManager from one of the parents.
    # (an earlier test showed maybe 2-3 different AuiManagers among the ancestors)
    while True:
        newam = wx.aui.AuiManager.GetManager(win)
        if str(am[-1]) != str(newam):
            if len(am) >= 2: # This sets how many generations to go back
    print len(am)
    m_panel6 = wx.Panel( None, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER|wx.TAB_TRAVERSAL )
    am[-1].AddPane( m_panel6, wx.aui.AuiPaneInfo() .Center() .Caption( u"who are you" ).PinButton( True ).Gripper().Float().FloatingPosition( wx.Point( 346,268 ) ).Resizable().FloatingSize( wx.Size( 474,60 ) ).Layer( 0 ) )


Anyone have any tips to get this to integrate properly?

Hi Greg,

One of the devs here.

As you’ve probably noticed, our Python API is somewhat unstable. While the core classes, like BOARD/BOARD_ITEM are not likely to change a lot in the foreseeable future, this can’t be said about anything related to the GUI.

The view layer sets feature is something pcbnew badly deserves, and - IMHO - it should become a core part of Kicad, not even a plugin (unless we’ll have a stable GUI/tools python interface, which is a long way to go). Would you be interested in porting it to C++? Help with integration in pcbnew offered.


1 Like

I totally agree. It should be part of the core. I can get started with KiCad C++ in mid October. I’m using this time with python to learn some of the details of KiCad code base before I set up the development environment for compiling. Some of the problems I’ve had have influenced me in diving into the C++ code. Plus, python development can be iterated with users to try out different designs and features before “freezing” it in C where there is a longer iteration time.

I think the UI will port well since it’s all based on wx, and the code (especially in the case of layerviewset) is very small and straightforward. I’ve wanted a “view stack” for a long time (in professional layout tools as well), but have never seen it elsewhere. Easy to do the “push”, change layer view, make layout modification, then “pop” the view back to where it was. All without saving to and loading from a file.

This will get into core KiCad code eventually, either by me or if someone else gets to it first!

1 Like

I’ve almost figured it out! Progress in this thread.