0321 from macmini

This commit is contained in:
2025-03-21 13:28:36 +08:00
commit cd1fd4bdfa
11397 changed files with 4528845 additions and 0 deletions

View File

@ -0,0 +1 @@
from .settings_dialog import SettingsDialog, GeneralSettingsPanel

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

View File

@ -0,0 +1,578 @@
# -*- coding: utf-8 -*-
###########################################################################
## Python code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
###########################################################################
import wx
import wx.xrc
import wx.grid
###########################################################################
## Class SettingsDialogBase
###########################################################################
class SettingsDialogBase ( wx.Dialog ):
def __init__( self, parent ):
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"InteractiveHtmlBom", pos = wx.DefaultPosition, size = wx.Size( 463,497 ), style = wx.DEFAULT_DIALOG_STYLE|wx.STAY_ON_TOP|wx.BORDER_DEFAULT )
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
self.Centre( wx.BOTH )
def __del__( self ):
pass
###########################################################################
## Class SettingsDialogPanel
###########################################################################
class SettingsDialogPanel ( wx.Panel ):
def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 400,300 ), style = wx.TAB_TRAVERSAL, name = wx.EmptyString ):
wx.Panel.__init__ ( self, parent, id = id, pos = pos, size = size, style = style, name = name )
bSizer20 = wx.BoxSizer( wx.VERTICAL )
self.notebook = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.NB_TOP|wx.BORDER_DEFAULT )
bSizer20.Add( self.notebook, 1, wx.EXPAND |wx.ALL, 5 )
bSizer39 = wx.BoxSizer( wx.HORIZONTAL )
self.saveSettingsBtn = wx.Button( self, wx.ID_ANY, u"Save current settings...", wx.DefaultPosition, wx.DefaultSize, 0|wx.BORDER_DEFAULT )
bSizer39.Add( self.saveSettingsBtn, 0, wx.ALL, 5 )
bSizer39.Add( ( 50, 0), 1, wx.EXPAND, 5 )
self.generateBomBtn = wx.Button( self, wx.ID_ANY, u"Generate BOM", wx.DefaultPosition, wx.DefaultSize, 0|wx.BORDER_DEFAULT )
self.generateBomBtn.SetDefault()
bSizer39.Add( self.generateBomBtn, 0, wx.ALL, 5 )
self.cancelBtn = wx.Button( self, wx.ID_CANCEL, u"Cancel", wx.DefaultPosition, wx.DefaultSize, 0|wx.BORDER_DEFAULT )
bSizer39.Add( self.cancelBtn, 0, wx.ALL, 5 )
bSizer20.Add( bSizer39, 0, wx.EXPAND, 5 )
self.SetSizer( bSizer20 )
self.Layout()
# Connect Events
self.saveSettingsBtn.Bind( wx.EVT_BUTTON, self.OnSave )
self.generateBomBtn.Bind( wx.EVT_BUTTON, self.OnGenerateBom )
self.cancelBtn.Bind( wx.EVT_BUTTON, self.OnExit )
def __del__( self ):
pass
# Virtual event handlers, override them in your derived class
def OnSave( self, event ):
event.Skip()
def OnGenerateBom( self, event ):
event.Skip()
def OnExit( self, event ):
event.Skip()
###########################################################################
## Class HtmlSettingsPanelBase
###########################################################################
class HtmlSettingsPanelBase ( wx.Panel ):
def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL, name = wx.EmptyString ):
wx.Panel.__init__ ( self, parent, id = id, pos = pos, size = size, style = style, name = name )
b_sizer = wx.BoxSizer( wx.VERTICAL )
self.darkModeCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Dark mode", wx.DefaultPosition, wx.DefaultSize, 0 )
b_sizer.Add( self.darkModeCheckbox, 0, wx.ALL, 5 )
self.showPadsCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Show footprint pads", wx.DefaultPosition, wx.DefaultSize, 0 )
self.showPadsCheckbox.SetValue(True)
b_sizer.Add( self.showPadsCheckbox, 0, wx.ALL, 5 )
self.showFabricationCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Show fabrication layer", wx.DefaultPosition, wx.DefaultSize, 0 )
b_sizer.Add( self.showFabricationCheckbox, 0, wx.ALL, 5 )
self.showSilkscreenCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Show silkscreen", wx.DefaultPosition, wx.DefaultSize, 0 )
self.showSilkscreenCheckbox.SetValue(True)
b_sizer.Add( self.showSilkscreenCheckbox, 0, wx.ALL, 5 )
self.continuousRedrawCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Continuous redraw on drag", wx.DefaultPosition, wx.DefaultSize, 0 )
self.continuousRedrawCheckbox.SetValue(True)
b_sizer.Add( self.continuousRedrawCheckbox, 0, wx.ALL, 5 )
highlightPin1Choices = [ u"None", u"All", u"Selected" ]
self.highlightPin1 = wx.RadioBox( self, wx.ID_ANY, u"Highlight first pin", wx.DefaultPosition, wx.DefaultSize, highlightPin1Choices, 3, wx.RA_SPECIFY_COLS )
self.highlightPin1.SetSelection( 0 )
b_sizer.Add( self.highlightPin1, 0, wx.ALL|wx.EXPAND, 5 )
bSizer18 = wx.BoxSizer( wx.VERTICAL )
bSizer19 = wx.BoxSizer( wx.HORIZONTAL )
self.m_boardRotationLabel = wx.StaticText( self, wx.ID_ANY, u"Board rotation", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_boardRotationLabel.Wrap( -1 )
bSizer19.Add( self.m_boardRotationLabel, 0, wx.ALL, 5 )
bSizer19.Add( ( 0, 0), 1, wx.EXPAND, 5 )
self.rotationDegreeLabel = wx.StaticText( self, wx.ID_ANY, u"0", wx.DefaultPosition, wx.Size( 30,-1 ), wx.ALIGN_RIGHT|wx.ST_NO_AUTORESIZE )
self.rotationDegreeLabel.Wrap( -1 )
bSizer19.Add( self.rotationDegreeLabel, 0, wx.ALL, 5 )
bSizer19.Add( ( 8, 0), 0, 0, 5 )
bSizer18.Add( bSizer19, 1, wx.EXPAND, 5 )
self.boardRotationSlider = wx.Slider( self, wx.ID_ANY, 0, -36, 36, wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL )
bSizer18.Add( self.boardRotationSlider, 0, wx.ALL|wx.EXPAND, 5 )
b_sizer.Add( bSizer18, 0, wx.EXPAND, 5 )
self.offsetBackRotationCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Offset back rotation", wx.DefaultPosition, wx.DefaultSize, 0 )
b_sizer.Add( self.offsetBackRotationCheckbox, 0, wx.ALL, 5 )
sbSizer31 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Checkboxes" ), wx.HORIZONTAL )
self.bomCheckboxesCtrl = wx.TextCtrl( sbSizer31.GetStaticBox(), wx.ID_ANY, u"Sourced,Placed", wx.DefaultPosition, wx.DefaultSize, 0 )
sbSizer31.Add( self.bomCheckboxesCtrl, 1, wx.ALL, 5 )
b_sizer.Add( sbSizer31, 0, wx.ALL|wx.EXPAND, 5 )
bomDefaultViewChoices = [ u"BOM only", u"BOM left, drawings right", u"BOM top, drawings bottom" ]
self.bomDefaultView = wx.RadioBox( self, wx.ID_ANY, u"BOM View", wx.DefaultPosition, wx.DefaultSize, bomDefaultViewChoices, 1, wx.RA_SPECIFY_COLS )
self.bomDefaultView.SetSelection( 1 )
b_sizer.Add( self.bomDefaultView, 0, wx.ALL|wx.EXPAND, 5 )
layerDefaultViewChoices = [ u"Front only", u"Front and Back", u"Back only" ]
self.layerDefaultView = wx.RadioBox( self, wx.ID_ANY, u"Layer View", wx.DefaultPosition, wx.DefaultSize, layerDefaultViewChoices, 1, wx.RA_SPECIFY_COLS )
self.layerDefaultView.SetSelection( 1 )
b_sizer.Add( self.layerDefaultView, 0, wx.ALL|wx.EXPAND, 5 )
sbSizer10 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Miscellaneous" ), wx.VERTICAL )
self.compressionCheckbox = wx.CheckBox( sbSizer10.GetStaticBox(), wx.ID_ANY, u"Enable compression", wx.DefaultPosition, wx.DefaultSize, 0 )
self.compressionCheckbox.SetValue(True)
sbSizer10.Add( self.compressionCheckbox, 0, wx.ALL, 5 )
self.openBrowserCheckbox = wx.CheckBox( sbSizer10.GetStaticBox(), wx.ID_ANY, u"Open browser", wx.DefaultPosition, wx.DefaultSize, 0 )
self.openBrowserCheckbox.SetValue(True)
sbSizer10.Add( self.openBrowserCheckbox, 0, wx.ALL, 5 )
b_sizer.Add( sbSizer10, 1, wx.EXPAND|wx.ALL, 5 )
self.SetSizer( b_sizer )
self.Layout()
b_sizer.Fit( self )
# Connect Events
self.boardRotationSlider.Bind( wx.EVT_SLIDER, self.OnBoardRotationSlider )
def __del__( self ):
pass
# Virtual event handlers, override them in your derived class
def OnBoardRotationSlider( self, event ):
event.Skip()
###########################################################################
## Class GeneralSettingsPanelBase
###########################################################################
class GeneralSettingsPanelBase ( wx.Panel ):
def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL, name = wx.EmptyString ):
wx.Panel.__init__ ( self, parent, id = id, pos = pos, size = size, style = style, name = name )
bSizer32 = wx.BoxSizer( wx.VERTICAL )
sbSizer6 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Bom destination" ), wx.VERTICAL )
fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
fgSizer1.AddGrowableCol( 1 )
fgSizer1.SetFlexibleDirection( wx.BOTH )
fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
self.m_staticText8 = wx.StaticText( sbSizer6.GetStaticBox(), wx.ID_ANY, u"Directory", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText8.Wrap( -1 )
fgSizer1.Add( self.m_staticText8, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
self.bomDirPicker = wx.DirPickerCtrl( sbSizer6.GetStaticBox(), wx.ID_ANY, wx.EmptyString, u"Select bom folder", wx.DefaultPosition, wx.DefaultSize, wx.DIRP_SMALL|wx.DIRP_USE_TEXTCTRL|wx.BORDER_SIMPLE )
fgSizer1.Add( self.bomDirPicker, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
self.m_staticText9 = wx.StaticText( sbSizer6.GetStaticBox(), wx.ID_ANY, u"Name format", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText9.Wrap( -1 )
fgSizer1.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
bSizer20 = wx.BoxSizer( wx.HORIZONTAL )
self.fileNameFormatTextControl = wx.TextCtrl( sbSizer6.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer20.Add( self.fileNameFormatTextControl, 1, wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM|wx.LEFT|wx.TOP, 5 )
self.m_btnNameHint = wx.Button( sbSizer6.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnNameHint.SetMinSize( wx.Size( 30,30 ) )
bSizer20.Add( self.m_btnNameHint, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
fgSizer1.Add( bSizer20, 1, wx.EXPAND, 5 )
sbSizer6.Add( fgSizer1, 1, wx.EXPAND, 5 )
bSizer32.Add( sbSizer6, 0, wx.ALL|wx.EXPAND, 5 )
sbSizer9 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Additional pcb data" ), wx.HORIZONTAL )
self.includeTracksCheckbox = wx.CheckBox( sbSizer9.GetStaticBox(), wx.ID_ANY, u"Include tracks/zones", wx.DefaultPosition, wx.DefaultSize, 0 )
sbSizer9.Add( self.includeTracksCheckbox, 1, wx.ALL, 5 )
self.includeNetsCheckbox = wx.CheckBox( sbSizer9.GetStaticBox(), wx.ID_ANY, u"Include nets", wx.DefaultPosition, wx.DefaultSize, 0 )
sbSizer9.Add( self.includeNetsCheckbox, 1, wx.ALL, 5 )
bSizer32.Add( sbSizer9, 0, wx.ALL|wx.EXPAND, 5 )
sortingSizer = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Component sort order" ), wx.VERTICAL )
bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
bSizer6 = wx.BoxSizer( wx.VERTICAL )
componentSortOrderBoxChoices = []
self.componentSortOrderBox = wx.ListBox( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, componentSortOrderBoxChoices, wx.LB_SINGLE|wx.BORDER_SIMPLE )
bSizer6.Add( self.componentSortOrderBox, 1, wx.ALL|wx.EXPAND, 5 )
bSizer4.Add( bSizer6, 1, wx.EXPAND, 5 )
bSizer5 = wx.BoxSizer( wx.VERTICAL )
self.m_btnSortUp = wx.Button( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnSortUp.SetMinSize( wx.Size( 30,30 ) )
bSizer5.Add( self.m_btnSortUp, 0, wx.ALL, 5 )
self.m_btnSortDown = wx.Button( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnSortDown.SetMinSize( wx.Size( 30,30 ) )
bSizer5.Add( self.m_btnSortDown, 0, wx.ALL, 5 )
self.m_btnSortAdd = wx.Button( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnSortAdd.SetMinSize( wx.Size( 30,30 ) )
bSizer5.Add( self.m_btnSortAdd, 0, wx.ALL, 5 )
self.m_btnSortRemove = wx.Button( sortingSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnSortRemove.SetMinSize( wx.Size( 30,30 ) )
bSizer5.Add( self.m_btnSortRemove, 0, wx.ALL, 5 )
bSizer4.Add( bSizer5, 0, 0, 5 )
sortingSizer.Add( bSizer4, 1, wx.EXPAND, 5 )
bSizer32.Add( sortingSizer, 1, wx.ALL|wx.EXPAND, 5 )
blacklistSizer = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Component blacklist" ), wx.VERTICAL )
bSizer412 = wx.BoxSizer( wx.HORIZONTAL )
bSizer612 = wx.BoxSizer( wx.VERTICAL )
blacklistBoxChoices = []
self.blacklistBox = wx.ListBox( blacklistSizer.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, blacklistBoxChoices, wx.LB_SINGLE|wx.LB_SORT|wx.BORDER_SIMPLE )
bSizer612.Add( self.blacklistBox, 1, wx.ALL|wx.EXPAND, 5 )
bSizer412.Add( bSizer612, 1, wx.EXPAND, 5 )
bSizer512 = wx.BoxSizer( wx.VERTICAL )
self.m_btnBlacklistAdd = wx.Button( blacklistSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnBlacklistAdd.SetMinSize( wx.Size( 30,30 ) )
bSizer512.Add( self.m_btnBlacklistAdd, 0, wx.ALL, 5 )
self.m_btnBlacklistRemove = wx.Button( blacklistSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnBlacklistRemove.SetMinSize( wx.Size( 30,30 ) )
bSizer512.Add( self.m_btnBlacklistRemove, 0, wx.ALL, 5 )
bSizer412.Add( bSizer512, 0, 0, 5 )
blacklistSizer.Add( bSizer412, 1, wx.EXPAND, 5 )
self.m_staticText1 = wx.StaticText( blacklistSizer.GetStaticBox(), wx.ID_ANY, u"Globs are supported, e.g. MH*", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText1.Wrap( -1 )
blacklistSizer.Add( self.m_staticText1, 0, wx.ALL, 5 )
self.blacklistVirtualCheckbox = wx.CheckBox( blacklistSizer.GetStaticBox(), wx.ID_ANY, u"Blacklist virtual components", wx.DefaultPosition, wx.DefaultSize, 0 )
self.blacklistVirtualCheckbox.SetValue(True)
blacklistSizer.Add( self.blacklistVirtualCheckbox, 0, wx.ALL, 5 )
self.blacklistEmptyValCheckbox = wx.CheckBox( blacklistSizer.GetStaticBox(), wx.ID_ANY, u"Blacklist components with empty value", wx.DefaultPosition, wx.DefaultSize, 0 )
blacklistSizer.Add( self.blacklistEmptyValCheckbox, 0, wx.ALL, 5 )
bSizer32.Add( blacklistSizer, 1, wx.ALL|wx.EXPAND|wx.TOP, 5 )
self.SetSizer( bSizer32 )
self.Layout()
bSizer32.Fit( self )
# Connect Events
self.Bind( wx.EVT_SIZE, self.OnSize )
self.m_btnNameHint.Bind( wx.EVT_BUTTON, self.OnNameFormatHintClick )
self.m_btnSortUp.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderUp )
self.m_btnSortDown.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderDown )
self.m_btnSortAdd.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderAdd )
self.m_btnSortRemove.Bind( wx.EVT_BUTTON, self.OnComponentSortOrderRemove )
self.m_btnBlacklistAdd.Bind( wx.EVT_BUTTON, self.OnComponentBlacklistAdd )
self.m_btnBlacklistRemove.Bind( wx.EVT_BUTTON, self.OnComponentBlacklistRemove )
def __del__( self ):
pass
# Virtual event handlers, override them in your derived class
def OnSize( self, event ):
event.Skip()
def OnNameFormatHintClick( self, event ):
event.Skip()
def OnComponentSortOrderUp( self, event ):
event.Skip()
def OnComponentSortOrderDown( self, event ):
event.Skip()
def OnComponentSortOrderAdd( self, event ):
event.Skip()
def OnComponentSortOrderRemove( self, event ):
event.Skip()
def OnComponentBlacklistAdd( self, event ):
event.Skip()
def OnComponentBlacklistRemove( self, event ):
event.Skip()
###########################################################################
## Class FieldsPanelBase
###########################################################################
class FieldsPanelBase ( wx.Panel ):
def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL, name = wx.EmptyString ):
wx.Panel.__init__ ( self, parent, id = id, pos = pos, size = size, style = style, name = name )
bSizer42 = wx.BoxSizer( wx.VERTICAL )
sbSizer7 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Extra data file" ), wx.VERTICAL )
self.extraDataFilePicker = wx.FilePickerCtrl( sbSizer7.GetStaticBox(), wx.ID_ANY, wx.EmptyString, u"Select a file", u"Netlist and xml files (*.net; *.xml)|*.net;*.xml", wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE|wx.FLP_FILE_MUST_EXIST|wx.FLP_OPEN|wx.FLP_SMALL|wx.FLP_USE_TEXTCTRL|wx.BORDER_SIMPLE )
sbSizer7.Add( self.extraDataFilePicker, 0, wx.EXPAND|wx.BOTTOM|wx.RIGHT|wx.LEFT, 5 )
bSizer42.Add( sbSizer7, 0, wx.ALL|wx.EXPAND, 5 )
fieldsSizer = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Fields" ), wx.VERTICAL )
bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
self.fieldsGrid = wx.grid.Grid( fieldsSizer.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
# Grid
self.fieldsGrid.CreateGrid( 2, 3 )
self.fieldsGrid.EnableEditing( True )
self.fieldsGrid.EnableGridLines( True )
self.fieldsGrid.EnableDragGridSize( False )
self.fieldsGrid.SetMargins( 0, 0 )
# Columns
self.fieldsGrid.AutoSizeColumns()
self.fieldsGrid.EnableDragColMove( False )
self.fieldsGrid.EnableDragColSize( True )
self.fieldsGrid.SetColLabelValue( 0, u"Show" )
self.fieldsGrid.SetColLabelValue( 1, u"Group" )
self.fieldsGrid.SetColLabelValue( 2, u"Name" )
self.fieldsGrid.SetColLabelSize( 30 )
self.fieldsGrid.SetColLabelAlignment( wx.ALIGN_CENTER, wx.ALIGN_CENTER )
# Rows
self.fieldsGrid.EnableDragRowSize( False )
self.fieldsGrid.SetRowLabelSize( 0 )
self.fieldsGrid.SetRowLabelAlignment( wx.ALIGN_CENTER, wx.ALIGN_CENTER )
# Label Appearance
# Cell Defaults
self.fieldsGrid.SetDefaultCellAlignment( wx.ALIGN_CENTER, wx.ALIGN_TOP )
self.fieldsGrid.SetMaxSize( wx.Size( -1,200 ) )
bSizer4.Add( self.fieldsGrid, 1, wx.ALL|wx.EXPAND, 5 )
bSizer5 = wx.BoxSizer( wx.VERTICAL )
self.m_btnUp = wx.Button( fieldsSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnUp.SetMinSize( wx.Size( 30,30 ) )
bSizer5.Add( self.m_btnUp, 0, wx.ALL, 5 )
self.m_btnDown = wx.Button( fieldsSizer.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT )
self.m_btnDown.SetMinSize( wx.Size( 30,30 ) )
bSizer5.Add( self.m_btnDown, 0, wx.ALL, 5 )
bSizer4.Add( bSizer5, 0, 0, 5 )
fieldsSizer.Add( bSizer4, 1, wx.EXPAND, 5 )
self.normalizeCaseCheckbox = wx.CheckBox( fieldsSizer.GetStaticBox(), wx.ID_ANY, u"Normalize field name case", wx.DefaultPosition, wx.DefaultSize, 0 )
fieldsSizer.Add( self.normalizeCaseCheckbox, 0, wx.ALL|wx.EXPAND, 5 )
bSizer42.Add( fieldsSizer, 2, wx.ALL|wx.EXPAND, 5 )
sbSizer32 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"Board variant" ), wx.VERTICAL )
self.m_staticText5 = wx.StaticText( sbSizer32.GetStaticBox(), wx.ID_ANY, u"Board variant field name", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText5.Wrap( -1 )
sbSizer32.Add( self.m_staticText5, 0, wx.ALL, 5 )
boardVariantFieldBoxChoices = []
self.boardVariantFieldBox = wx.ComboBox( sbSizer32.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, boardVariantFieldBoxChoices, wx.CB_READONLY|wx.CB_SORT|wx.BORDER_SIMPLE )
sbSizer32.Add( self.boardVariantFieldBox, 0, wx.ALL|wx.EXPAND, 5 )
bSizer17 = wx.BoxSizer( wx.HORIZONTAL )
bSizer18 = wx.BoxSizer( wx.VERTICAL )
self.m_staticText6 = wx.StaticText( sbSizer32.GetStaticBox(), wx.ID_ANY, u"Whitelist", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText6.Wrap( -1 )
bSizer18.Add( self.m_staticText6, 0, wx.ALL, 5 )
boardVariantWhitelistChoices = []
self.boardVariantWhitelist = wx.CheckListBox( sbSizer32.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, boardVariantWhitelistChoices, 0|wx.BORDER_SIMPLE )
bSizer18.Add( self.boardVariantWhitelist, 1, wx.ALL|wx.EXPAND, 5 )
bSizer17.Add( bSizer18, 1, wx.EXPAND, 5 )
bSizer19 = wx.BoxSizer( wx.VERTICAL )
self.m_staticText7 = wx.StaticText( sbSizer32.GetStaticBox(), wx.ID_ANY, u"Blacklist", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText7.Wrap( -1 )
bSizer19.Add( self.m_staticText7, 0, wx.ALL, 5 )
boardVariantBlacklistChoices = []
self.boardVariantBlacklist = wx.CheckListBox( sbSizer32.GetStaticBox(), wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, boardVariantBlacklistChoices, 0|wx.BORDER_SIMPLE )
bSizer19.Add( self.boardVariantBlacklist, 1, wx.ALL|wx.EXPAND, 5 )
bSizer17.Add( bSizer19, 1, wx.EXPAND, 5 )
sbSizer32.Add( bSizer17, 1, wx.EXPAND, 5 )
bSizer42.Add( sbSizer32, 3, wx.ALL|wx.EXPAND, 5 )
sbSizer8 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"DNP field name" ), wx.VERTICAL )
self.m_staticText4 = wx.StaticText( sbSizer8.GetStaticBox(), wx.ID_ANY, u"Components with this field not empty will be ignored", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText4.Wrap( -1 )
sbSizer8.Add( self.m_staticText4, 0, wx.ALL, 5 )
dnpFieldBoxChoices = []
self.dnpFieldBox = wx.ComboBox( sbSizer8.GetStaticBox(), wx.ID_ANY, u"-None-", wx.DefaultPosition, wx.DefaultSize, dnpFieldBoxChoices, wx.CB_READONLY|wx.CB_SORT|wx.BORDER_NONE )
sbSizer8.Add( self.dnpFieldBox, 0, wx.ALL|wx.EXPAND, 5 )
bSizer42.Add( sbSizer8, 0, wx.ALL|wx.EXPAND, 5 )
self.SetSizer( bSizer42 )
self.Layout()
bSizer42.Fit( self )
# Connect Events
self.Bind( wx.EVT_SIZE, self.OnSize )
self.extraDataFilePicker.Bind( wx.EVT_FILEPICKER_CHANGED, self.OnExtraDataFileChanged )
self.fieldsGrid.Bind( wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnGridCellClicked )
self.m_btnUp.Bind( wx.EVT_BUTTON, self.OnFieldsUp )
self.m_btnDown.Bind( wx.EVT_BUTTON, self.OnFieldsDown )
self.normalizeCaseCheckbox.Bind( wx.EVT_CHECKBOX, self.OnExtraDataFileChanged )
self.boardVariantFieldBox.Bind( wx.EVT_COMBOBOX, self.OnBoardVariantFieldChange )
def __del__( self ):
pass
# Virtual event handlers, override them in your derived class
def OnSize( self, event ):
event.Skip()
def OnExtraDataFileChanged( self, event ):
event.Skip()
def OnGridCellClicked( self, event ):
event.Skip()
def OnFieldsUp( self, event ):
event.Skip()
def OnFieldsDown( self, event ):
event.Skip()
def OnBoardVariantFieldChange( self, event ):
event.Skip()

View File

@ -0,0 +1,406 @@
import os
import re
import wx
import wx.grid
from . import dialog_base
if hasattr(wx, "GetLibraryVersionInfo"):
WX_VERSION = wx.GetLibraryVersionInfo() # type: wx.VersionInfo
WX_VERSION = (WX_VERSION.Major, WX_VERSION.Minor, WX_VERSION.Micro)
else:
# old kicad used this (exact version doesnt matter)
WX_VERSION = (3, 0, 2)
def pop_error(msg):
wx.MessageBox(msg, 'Error', wx.OK | wx.ICON_ERROR)
def get_btn_bitmap(bitmap):
path = os.path.join(os.path.dirname(__file__), "bitmaps", bitmap)
png = wx.Bitmap(path, wx.BITMAP_TYPE_PNG)
if WX_VERSION >= (3, 1, 6):
return wx.BitmapBundle(png)
else:
return png
class SettingsDialog(dialog_base.SettingsDialogBase):
def __init__(self, extra_data_func, extra_data_wildcard, config_save_func,
file_name_format_hint, version):
dialog_base.SettingsDialogBase.__init__(self, None)
self.panel = SettingsDialogPanel(
self, extra_data_func, extra_data_wildcard, config_save_func,
file_name_format_hint)
best_size = self.panel.BestSize
# hack for some gtk themes that incorrectly calculate best size
best_size.IncBy(dx=0, dy=30)
self.SetClientSize(best_size)
self.SetTitle('InteractiveHtmlBom %s' % version)
# hack for new wxFormBuilder generating code incompatible with old wxPython
# noinspection PyMethodOverriding
def SetSizeHints(self, sz1, sz2):
try:
# wxPython 4
super(SettingsDialog, self).SetSizeHints(sz1, sz2)
except TypeError:
# wxPython 3
self.SetSizeHintsSz(sz1, sz2)
def set_extra_data_path(self, extra_data_file):
self.panel.fields.extraDataFilePicker.Path = extra_data_file
self.panel.fields.OnExtraDataFileChanged(None)
# Implementing settings_dialog
class SettingsDialogPanel(dialog_base.SettingsDialogPanel):
def __init__(self, parent, extra_data_func, extra_data_wildcard,
config_save_func, file_name_format_hint):
self.config_save_func = config_save_func
dialog_base.SettingsDialogPanel.__init__(self, parent)
self.general = GeneralSettingsPanel(self.notebook,
file_name_format_hint)
self.html = HtmlSettingsPanel(self.notebook)
self.fields = FieldsPanel(self.notebook, extra_data_func,
extra_data_wildcard)
self.notebook.AddPage(self.general, "General")
self.notebook.AddPage(self.html, "Html defaults")
self.notebook.AddPage(self.fields, "Fields")
self.save_menu = wx.Menu()
self.save_locally = self.save_menu.Append(
wx.ID_ANY, u"Locally", wx.EmptyString, wx.ITEM_NORMAL)
self.save_globally = self.save_menu.Append(
wx.ID_ANY, u"Globally", wx.EmptyString, wx.ITEM_NORMAL)
self.Bind(
wx.EVT_MENU, self.OnSaveLocally, id=self.save_locally.GetId())
self.Bind(
wx.EVT_MENU, self.OnSaveGlobally, id=self.save_globally.GetId())
def OnExit(self, event):
self.GetParent().EndModal(wx.ID_CANCEL)
def OnGenerateBom(self, event):
self.GetParent().EndModal(wx.ID_OK)
def finish_init(self):
self.html.OnBoardRotationSlider(None)
def OnSave(self, event):
# type: (wx.CommandEvent) -> None
pos = wx.Point(0, event.GetEventObject().GetSize().y)
self.saveSettingsBtn.PopupMenu(self.save_menu, pos)
def OnSaveGlobally(self, event):
self.config_save_func(self)
def OnSaveLocally(self, event):
self.config_save_func(self, locally=True)
# Implementing HtmlSettingsPanelBase
class HtmlSettingsPanel(dialog_base.HtmlSettingsPanelBase):
def __init__(self, parent):
dialog_base.HtmlSettingsPanelBase.__init__(self, parent)
# Handlers for HtmlSettingsPanelBase events.
def OnBoardRotationSlider(self, event):
degrees = self.boardRotationSlider.Value * 5
self.rotationDegreeLabel.LabelText = u"{}\u00B0".format(degrees)
# Implementing GeneralSettingsPanelBase
class GeneralSettingsPanel(dialog_base.GeneralSettingsPanelBase):
def __init__(self, parent, file_name_format_hint):
dialog_base.GeneralSettingsPanelBase.__init__(self, parent)
self.file_name_format_hint = file_name_format_hint
bmp_arrow_up = get_btn_bitmap("btn-arrow-up.png")
bmp_arrow_down = get_btn_bitmap("btn-arrow-down.png")
bmp_plus = get_btn_bitmap("btn-plus.png")
bmp_minus = get_btn_bitmap("btn-minus.png")
bmp_question = get_btn_bitmap("btn-question.png")
self.m_btnSortUp.SetBitmap(bmp_arrow_up)
self.m_btnSortDown.SetBitmap(bmp_arrow_down)
self.m_btnSortAdd.SetBitmap(bmp_plus)
self.m_btnSortRemove.SetBitmap(bmp_minus)
self.m_btnNameHint.SetBitmap(bmp_question)
self.m_btnBlacklistAdd.SetBitmap(bmp_plus)
self.m_btnBlacklistRemove.SetBitmap(bmp_minus)
self.Layout()
# Handlers for GeneralSettingsPanelBase events.
def OnComponentSortOrderUp(self, event):
selection = self.componentSortOrderBox.Selection
if selection != wx.NOT_FOUND and selection > 0:
item = self.componentSortOrderBox.GetString(selection)
self.componentSortOrderBox.Delete(selection)
self.componentSortOrderBox.Insert(item, selection - 1)
self.componentSortOrderBox.SetSelection(selection - 1)
def OnComponentSortOrderDown(self, event):
selection = self.componentSortOrderBox.Selection
size = self.componentSortOrderBox.Count
if selection != wx.NOT_FOUND and selection < size - 1:
item = self.componentSortOrderBox.GetString(selection)
self.componentSortOrderBox.Delete(selection)
self.componentSortOrderBox.Insert(item, selection + 1)
self.componentSortOrderBox.SetSelection(selection + 1)
def OnComponentSortOrderAdd(self, event):
item = wx.GetTextFromUser(
"Characters other than A-Z will be ignored.",
"Add sort order item")
item = re.sub('[^A-Z]', '', item.upper())
if item == '':
return
found = self.componentSortOrderBox.FindString(item)
if found != wx.NOT_FOUND:
self.componentSortOrderBox.SetSelection(found)
return
self.componentSortOrderBox.Append(item)
self.componentSortOrderBox.SetSelection(
self.componentSortOrderBox.Count - 1)
def OnComponentSortOrderRemove(self, event):
selection = self.componentSortOrderBox.Selection
if selection != wx.NOT_FOUND:
item = self.componentSortOrderBox.GetString(selection)
if item == '~':
pop_error("You can not delete '~' item")
return
self.componentSortOrderBox.Delete(selection)
if self.componentSortOrderBox.Count > 0:
self.componentSortOrderBox.SetSelection(max(selection - 1, 0))
def OnComponentBlacklistAdd(self, event):
item = wx.GetTextFromUser(
"Characters other than A-Z 0-9 and * will be ignored.",
"Add blacklist item")
item = re.sub('[^A-Z0-9*]', '', item.upper())
if item == '':
return
found = self.blacklistBox.FindString(item)
if found != wx.NOT_FOUND:
self.blacklistBox.SetSelection(found)
return
self.blacklistBox.Append(item)
self.blacklistBox.SetSelection(self.blacklistBox.Count - 1)
def OnComponentBlacklistRemove(self, event):
selection = self.blacklistBox.Selection
if selection != wx.NOT_FOUND:
self.blacklistBox.Delete(selection)
if self.blacklistBox.Count > 0:
self.blacklistBox.SetSelection(max(selection - 1, 0))
def OnNameFormatHintClick(self, event):
wx.MessageBox(self.file_name_format_hint, 'File name format help',
style=wx.ICON_NONE | wx.OK)
def OnSize(self, event):
# Trick the listCheckBox best size calculations
tmp = self.componentSortOrderBox.GetStrings()
self.componentSortOrderBox.SetItems([])
self.Layout()
self.componentSortOrderBox.SetItems(tmp)
# Implementing FieldsPanelBase
class FieldsPanel(dialog_base.FieldsPanelBase):
NONE_STRING = '<none>'
EMPTY_STRING = '<empty>'
FIELDS_GRID_COLUMNS = 3
def __init__(self, parent, extra_data_func, extra_data_wildcard):
dialog_base.FieldsPanelBase.__init__(self, parent)
self.show_fields = []
self.group_fields = []
self.extra_data_func = extra_data_func
self.extra_field_data = None
self.m_btnUp.SetBitmap(get_btn_bitmap("btn-arrow-up.png"))
self.m_btnDown.SetBitmap(get_btn_bitmap("btn-arrow-down.png"))
self.set_file_picker_wildcard(extra_data_wildcard)
self._setFieldsList([])
for i in range(2):
box = self.GetTextExtent(self.fieldsGrid.GetColLabelValue(i))
if hasattr(box, "x"):
width = box.x
else:
width = box[0]
width = int(width * 1.1 + 5)
self.fieldsGrid.SetColMinimalWidth(i, width)
self.fieldsGrid.SetColSize(i, width)
self.Layout()
def set_file_picker_wildcard(self, extra_data_wildcard):
if extra_data_wildcard is None:
self.extraDataFilePicker.Disable()
return
# wxFilePickerCtrl doesn't support changing wildcard at runtime
# so we have to replace it
picker_parent = self.extraDataFilePicker.GetParent()
new_picker = wx.FilePickerCtrl(
picker_parent, wx.ID_ANY, wx.EmptyString,
u"Select a file",
extra_data_wildcard,
wx.DefaultPosition, wx.DefaultSize,
(wx.FLP_DEFAULT_STYLE | wx.FLP_FILE_MUST_EXIST | wx.FLP_OPEN |
wx.FLP_SMALL | wx.FLP_USE_TEXTCTRL | wx.BORDER_SIMPLE))
self.GetSizer().Replace(self.extraDataFilePicker, new_picker,
recursive=True)
self.extraDataFilePicker.Destroy()
self.extraDataFilePicker = new_picker
self.extraDataFilePicker.Bind(
wx.EVT_FILEPICKER_CHANGED, self.OnExtraDataFileChanged)
self.Layout()
def _swapRows(self, a, b):
for i in range(self.FIELDS_GRID_COLUMNS):
va = self.fieldsGrid.GetCellValue(a, i)
vb = self.fieldsGrid.GetCellValue(b, i)
self.fieldsGrid.SetCellValue(a, i, vb)
self.fieldsGrid.SetCellValue(b, i, va)
# Handlers for FieldsPanelBase events.
def OnGridCellClicked(self, event):
self.fieldsGrid.ClearSelection()
self.fieldsGrid.SelectRow(event.Row)
if event.Col < 2:
# toggle checkbox
val = self.fieldsGrid.GetCellValue(event.Row, event.Col)
val = "" if val else "1"
self.fieldsGrid.SetCellValue(event.Row, event.Col, val)
# group shouldn't be enabled without show
if event.Col == 0 and val == "":
self.fieldsGrid.SetCellValue(event.Row, 1, val)
if event.Col == 1 and val == "1":
self.fieldsGrid.SetCellValue(event.Row, 0, val)
def OnFieldsUp(self, event):
selection = self.fieldsGrid.SelectedRows
if len(selection) == 1 and selection[0] > 0:
self._swapRows(selection[0], selection[0] - 1)
self.fieldsGrid.ClearSelection()
self.fieldsGrid.SelectRow(selection[0] - 1)
def OnFieldsDown(self, event):
selection = self.fieldsGrid.SelectedRows
size = self.fieldsGrid.NumberRows
if len(selection) == 1 and selection[0] < size - 1:
self._swapRows(selection[0], selection[0] + 1)
self.fieldsGrid.ClearSelection()
self.fieldsGrid.SelectRow(selection[0] + 1)
def _setFieldsList(self, fields):
if self.fieldsGrid.NumberRows:
self.fieldsGrid.DeleteRows(0, self.fieldsGrid.NumberRows)
self.fieldsGrid.AppendRows(len(fields))
row = 0
for f in fields:
self.fieldsGrid.SetCellValue(row, 0, "1")
self.fieldsGrid.SetCellValue(row, 1, "1")
self.fieldsGrid.SetCellRenderer(
row, 0, wx.grid.GridCellBoolRenderer())
self.fieldsGrid.SetCellRenderer(
row, 1, wx.grid.GridCellBoolRenderer())
self.fieldsGrid.SetCellValue(row, 2, f)
self.fieldsGrid.SetCellAlignment(
row, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
self.fieldsGrid.SetReadOnly(row, 2)
row += 1
def OnExtraDataFileChanged(self, event):
extra_data_file = self.extraDataFilePicker.Path
if not os.path.isfile(extra_data_file):
return
self.extra_field_data = None
try:
self.extra_field_data = self.extra_data_func(
extra_data_file, self.normalizeCaseCheckbox.Value)
except Exception as e:
pop_error(
"Failed to parse file %s\n\n%s" % (extra_data_file, e))
self.extraDataFilePicker.Path = ''
if self.extra_field_data is not None:
field_list = list(self.extra_field_data.fields)
self._setFieldsList(["Value", "Footprint"] + field_list)
self.SetCheckedFields()
field_list.append(self.NONE_STRING)
self.boardVariantFieldBox.SetItems(field_list)
self.boardVariantFieldBox.SetStringSelection(self.NONE_STRING)
self.boardVariantWhitelist.Clear()
self.boardVariantBlacklist.Clear()
self.dnpFieldBox.SetItems(field_list)
self.dnpFieldBox.SetStringSelection(self.NONE_STRING)
def OnBoardVariantFieldChange(self, event):
selection = self.boardVariantFieldBox.Value
if not selection or selection == self.NONE_STRING \
or self.extra_field_data is None:
self.boardVariantWhitelist.Clear()
self.boardVariantBlacklist.Clear()
return
variant_set = set()
for _, field_dict in self.extra_field_data.fields_by_ref.items():
if selection in field_dict:
v = field_dict[selection]
if v == "":
v = self.EMPTY_STRING
variant_set.add(v)
self.boardVariantWhitelist.SetItems(list(variant_set))
self.boardVariantBlacklist.SetItems(list(variant_set))
def OnSize(self, event):
self.Layout()
g = self.fieldsGrid
g.SetColSize(
2, g.GetClientSize().x - g.GetColSize(0) - g.GetColSize(1) - 30)
def GetShowFields(self):
result = []
for row in range(self.fieldsGrid.NumberRows):
if self.fieldsGrid.GetCellValue(row, 0) == "1":
result.append(self.fieldsGrid.GetCellValue(row, 2))
return result
def GetGroupFields(self):
result = []
for row in range(self.fieldsGrid.NumberRows):
if self.fieldsGrid.GetCellValue(row, 1) == "1":
result.append(self.fieldsGrid.GetCellValue(row, 2))
return result
def SetCheckedFields(self, show=None, group=None):
self.show_fields = show or self.show_fields
self.group_fields = group or self.group_fields
self.group_fields = [
s for s in self.group_fields if s in self.show_fields
]
current = []
for row in range(self.fieldsGrid.NumberRows):
current.append(self.fieldsGrid.GetCellValue(row, 2))
new = [s for s in current if s not in self.show_fields]
self._setFieldsList(self.show_fields + new)
for row in range(self.fieldsGrid.NumberRows):
field = self.fieldsGrid.GetCellValue(row, 2)
self.fieldsGrid.SetCellValue(
row, 0, "1" if field in self.show_fields else "")
self.fieldsGrid.SetCellValue(
row, 1, "1" if field in self.group_fields else "")