parent
18889bf2b1
commit
acac821489
|
|
@ -14,7 +14,7 @@ class Columns:
|
|||
#default columns for groups
|
||||
COL_GRP_QUANTITY = 'Quantity'
|
||||
|
||||
#all available (from KiCAD) columns
|
||||
#all available columns
|
||||
_COLUMNS_ALL = [
|
||||
COL_DESCRIPTION,
|
||||
COL_PART,
|
||||
|
|
@ -36,7 +36,7 @@ class Columns:
|
|||
COL_FP
|
||||
]
|
||||
|
||||
_COLUMNS_GROUPED = _COLUMNS_DEFAULT + [
|
||||
_COLUMNS_GROUPED = [
|
||||
COL_GRP_QUANTITY,
|
||||
]
|
||||
|
||||
|
|
@ -51,6 +51,8 @@ class Columns:
|
|||
#make a copy of the supplied columns
|
||||
self.columns = [col for col in cols]
|
||||
|
||||
self._checkDefaultColumns()
|
||||
|
||||
def _hasColumn(self, title):
|
||||
|
||||
title = title.lower()
|
||||
|
|
@ -61,6 +63,13 @@ class Columns:
|
|||
|
||||
return False
|
||||
|
||||
def _checkDefaultColumns(self):
|
||||
|
||||
#prepend any default columns that don't exist
|
||||
for c in self._COLUMNS_DEFAULT[::-1]:
|
||||
if c not in self.columns:
|
||||
self.columns = [c] + self.columns
|
||||
|
||||
"""
|
||||
Remove a column from the list. Specify either the heading or the index
|
||||
"""
|
||||
|
|
|
|||
66
KiBOM_GUI.py
66
KiBOM_GUI.py
|
|
@ -14,17 +14,45 @@ from KiBOM.columns import Columns
|
|||
|
||||
#import bomfunk_netlist_reader
|
||||
|
||||
class KiBOMColumnList(wx.CheckListBox):
|
||||
def __init__(self, parent):
|
||||
wx.CheckListBox.__init__(self, parent)
|
||||
|
||||
self.InitColumns(Columns._COLUMNS_DEFAULT)
|
||||
|
||||
def InitColumns(self, cols):
|
||||
|
||||
self.Clear()
|
||||
|
||||
self.AppendItems(cols)
|
||||
|
||||
|
||||
class KiBOMTable(wx.grid.Grid):
|
||||
def __init__(self, parent):
|
||||
wx.grid.Grid.__init__(self,parent)
|
||||
|
||||
#Setup default columns
|
||||
self.SetupColumns(Columns._COLUMNS_DEFAULT)
|
||||
self.InitColumns()
|
||||
|
||||
#configure column headings
|
||||
def SetupColumns(self, columns):
|
||||
def InitColumns(self):
|
||||
|
||||
self.CreateGrid(0, len(columns))
|
||||
self.CreateGrid(0, 1)
|
||||
|
||||
self.SetColLabelValue(0,"Unitialized")
|
||||
|
||||
"""
|
||||
Perform a complete refresh of the columns
|
||||
"""
|
||||
def SetColumns(self, columns):
|
||||
|
||||
#add in any required rows
|
||||
if self.GetNumberCols() < len(columns):
|
||||
self.AppendCols(len(columns) - self.GetNumberCols())
|
||||
|
||||
#remove any rows as required
|
||||
if self.GetNumberCols() > len(columns):
|
||||
self.DeleteCols(self.GetNumberCols() - len(columns))
|
||||
|
||||
for i,h in enumerate(columns):
|
||||
self.SetColLabelValue(i,h)
|
||||
|
|
@ -34,10 +62,14 @@ class KiBOMFrame(wx.Frame):
|
|||
def __init__(self, parent, title):
|
||||
wx.Frame.__init__(self, parent,title=title)
|
||||
|
||||
self.columns = Columns()
|
||||
|
||||
self.panel = wx.Panel(self)
|
||||
|
||||
self.table = KiBOMTable(self.panel)
|
||||
|
||||
self.table.SetColumns(self.columns.columns)
|
||||
|
||||
#Vertical sizer that separates the "export options" (lower) from the main table and selectors
|
||||
self.hSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
|
|
@ -53,6 +85,34 @@ class KiBOMFrame(wx.Frame):
|
|||
|
||||
self.optSizer.Add(self.showHideSizer)
|
||||
|
||||
#list of available columns
|
||||
self.colListSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
self.colListTitle = wx.StaticText(self.panel, label="Columns:", style=wx.ALIGN_LEFT)
|
||||
self.colListSizer.Add(self.colListTitle)
|
||||
|
||||
self.colList = KiBOMColumnList(self.panel)
|
||||
self.colListSizer.Add(self.colList)
|
||||
|
||||
#buttons to move/add/delete columns
|
||||
self.colButtons = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
self.moveColUp = wx.Button(self.panel, label="Up")
|
||||
self.moveColDown = wx.Button(self.panel, label="Down")
|
||||
self.newCol = wx.Button(self.panel, label="Add")
|
||||
self.delCol = wx.Button(self.panel, label="Del")
|
||||
|
||||
#add the buttons
|
||||
self.colButtons.Add(self.moveColUp)
|
||||
self.colButtons.Add(self.moveColDown)
|
||||
self.colButtons.Add(self.delCol)
|
||||
self.colButtons.Add(self.newCol)
|
||||
|
||||
self.colListSizer.Add(self.colButtons)
|
||||
|
||||
self.optSizer.Add(self.colListSizer)
|
||||
|
||||
#add the main layout widgets
|
||||
self.hSizer.Add(self.optSizer)
|
||||
self.hSizer.Add(self.table, 1, wx.EXPAND)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue